Browse Source

Merge branch 'main' into refactor_model_download

Alex Cheema 10 months ago
parent
commit
67c269076b
1 changed files with 13 additions and 12 deletions
  1. 13 12
      exo/api/chatgpt_api.py

+ 13 - 12
exo/api/chatgpt_api.py

@@ -284,18 +284,19 @@ class ChatGPTAPI:
     if DEBUG >= 4: print(f"Resolved tokenizer: {tokenizer}")
     if DEBUG >= 4: print(f"Resolved tokenizer: {tokenizer}")
 
 
     prompt, image_str = build_prompt(tokenizer, chat_request.messages)
     prompt, image_str = build_prompt(tokenizer, chat_request.messages)
-    request_id = None
-    match = self.prompts.find_longest_prefix(prompt)
-    if match and len(prompt) > len(match[1].prompt):
-        if DEBUG >= 2:
-          print(f"Prompt for request starts with previous prompt {len(match[1].prompt)} of {len(prompt)}: {match[1].prompt}")
-        request_id = match[1].request_id
-        self.prompts.add(prompt, PromptSession(request_id=request_id, timestamp=int(time.time()), prompt=prompt))
-        # remove the matching prefix from the prompt
-        prompt = prompt[len(match[1].prompt):]
-    else:
-      request_id = str(uuid.uuid4())
-      self.prompts.add(prompt, PromptSession(request_id=request_id, timestamp=int(time.time()), prompt=prompt))
+    request_id = str(uuid.uuid4())
+    # request_id = None
+    # match = self.prompts.find_longest_prefix(prompt)
+    # if match and len(prompt) > len(match[1].prompt):
+    #     if DEBUG >= 2:
+    #       print(f"Prompt for request starts with previous prompt {len(match[1].prompt)} of {len(prompt)}: {match[1].prompt}")
+    #     request_id = match[1].request_id
+    #     self.prompts.add(prompt, PromptSession(request_id=request_id, timestamp=int(time.time()), prompt=prompt))
+    #     # remove the matching prefix from the prompt
+    #     prompt = prompt[len(match[1].prompt):]
+    # else:
+    #   request_id = str(uuid.uuid4())
+    #   self.prompts.add(prompt, PromptSession(request_id=request_id, timestamp=int(time.time()), prompt=prompt))
 
 
     callback_id = f"chatgpt-api-wait-response-{request_id}"
     callback_id = f"chatgpt-api-wait-response-{request_id}"
     callback = self.node.on_token.register(callback_id)
     callback = self.node.on_token.register(callback_id)