Update app.py
Browse files
app.py
CHANGED
@@ -56,10 +56,9 @@ def call_api(history, max_tokens, temperature, top_p, system_message="", seed=42
|
|
56 |
full_response = ""
|
57 |
for line in response.iter_lines():
|
58 |
if line:
|
59 |
-
decoded_line = line.decode("utf-8")
|
60 |
-
|
61 |
-
|
62 |
-
json_data = json.loads(decoded_line.replace("data:", ""))
|
63 |
if "choices" in json_data and len(json_data["choices"]) > 0:
|
64 |
deltas = json_data["choices"][0].get("delta", {})
|
65 |
if "content" in deltas:
|
@@ -67,6 +66,7 @@ def call_api(history, max_tokens, temperature, top_p, system_message="", seed=42
|
|
67 |
print(f"Full API response: {full_response}")
|
68 |
return full_response
|
69 |
|
|
|
70 |
def chat(history, system_message, max_tokens, temperature, top_p, top_k, repetition_penalty):
|
71 |
print("Starting chat...")
|
72 |
system_message_to_use = system_message if system_message.strip() else BASE_SYSTEM_MESSAGE
|
|
|
56 |
full_response = ""
|
57 |
for line in response.iter_lines():
|
58 |
if line:
|
59 |
+
decoded_line = line.decode("utf-8").strip()
|
60 |
+
if decoded_line.startswith("data:"):
|
61 |
+
json_data = json.loads(decoded_line[5:])
|
|
|
62 |
if "choices" in json_data and len(json_data["choices"]) > 0:
|
63 |
deltas = json_data["choices"][0].get("delta", {})
|
64 |
if "content" in deltas:
|
|
|
66 |
print(f"Full API response: {full_response}")
|
67 |
return full_response
|
68 |
|
69 |
+
|
70 |
def chat(history, system_message, max_tokens, temperature, top_p, top_k, repetition_penalty):
|
71 |
print("Starting chat...")
|
72 |
system_message_to_use = system_message if system_message.strip() else BASE_SYSTEM_MESSAGE
|