Spaces:
Sleeping
Sleeping
ogegadavis254
commited on
Commit
•
bf8b0f5
1
Parent(s):
c9f2e48
Update app.py
Browse files
app.py
CHANGED
@@ -95,7 +95,8 @@ def interact_with_together_api(messages):
|
|
95 |
|
96 |
# Check for the completion signal
|
97 |
if decoded_line == "data: [DONE]":
|
98 |
-
|
|
|
99 |
break
|
100 |
|
101 |
try:
|
@@ -105,7 +106,7 @@ def interact_with_together_api(messages):
|
|
105 |
chunk_data = json.loads(decoded_line)
|
106 |
content = chunk_data['choices'][0]['delta']['content']
|
107 |
entire_assistant_response += content # Aggregate content
|
108 |
-
yield
|
109 |
|
110 |
except json.JSONDecodeError:
|
111 |
print(f"Invalid JSON received: {decoded_line}")
|
|
|
95 |
|
96 |
# Check for the completion signal
|
97 |
if decoded_line == "data: [DONE]":
|
98 |
+
if entire_assistant_response:
|
99 |
+
yield entire_assistant_response # Yield the entire response at the end
|
100 |
break
|
101 |
|
102 |
try:
|
|
|
106 |
chunk_data = json.loads(decoded_line)
|
107 |
content = chunk_data['choices'][0]['delta']['content']
|
108 |
entire_assistant_response += content # Aggregate content
|
109 |
+
yield content # Yield each chunk separately
|
110 |
|
111 |
except json.JSONDecodeError:
|
112 |
print(f"Invalid JSON received: {decoded_line}")
|