Spaces:
Build error
Build error
Update app.py
Browse files
app.py
CHANGED
|
@@ -112,33 +112,21 @@ def respond(message, api_key, max_tokens, top_p, temperature):
|
|
| 112 |
|
| 113 |
print(f"Received line: {line}")
|
| 114 |
|
| 115 |
-
|
| 116 |
-
line_content = line[5:].strip()
|
| 117 |
-
if not line_content:
|
| 118 |
-
continue
|
| 119 |
-
|
| 120 |
-
try:
|
| 121 |
-
chunk = json.loads(line_content)
|
| 122 |
-
chunk_message = chunk.get("chunk", {}).get("content", "")
|
| 123 |
-
assistant_reply += chunk_message
|
| 124 |
-
yield assistant_reply
|
| 125 |
-
except json.JSONDecodeError as e:
|
| 126 |
-
print(f"Stream chunk error: {e} with line: {line_content}")
|
| 127 |
-
yield f"Error in stream chunk: {e}" # Optionally notify the user
|
| 128 |
-
continue
|
| 129 |
-
|
| 130 |
line_content = line[5:].strip()
|
| 131 |
if not line_content:
|
| 132 |
-
|
| 133 |
-
|
| 134 |
-
|
| 135 |
-
|
| 136 |
-
|
| 137 |
-
|
| 138 |
-
|
| 139 |
-
|
| 140 |
-
|
| 141 |
-
|
|
|
|
|
|
|
| 142 |
|
| 143 |
history.append((message, assistant_reply, "You", "P-ALPLE", sessions[api_key]["avatar"], ASSISTANT_PIC_PATH))
|
| 144 |
sessions[api_key]["history"] = history
|
|
|
|
| 112 |
|
| 113 |
print(f"Received line: {line}")
|
| 114 |
|
| 115 |
+
if line.startswith("data:"):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 116 |
line_content = line[5:].strip()
|
| 117 |
if not line_content:
|
| 118 |
+
continue
|
| 119 |
+
|
| 120 |
+
try:
|
| 121 |
+
chunk = json.loads(line_content)
|
| 122 |
+
chunk_message = chunk.get("chunk", {}).get("content", "")
|
| 123 |
+
assistant_reply += chunk_message
|
| 124 |
+
yield assistant_reply
|
| 125 |
+
except json.JSONDecodeError as e:
|
| 126 |
+
print(f"Stream chunk error: {e} with line: {line_content}")
|
| 127 |
+
yield f"Error in stream chunk: {e}" # Optionally notify the user
|
| 128 |
+
continue
|
| 129 |
+
|
| 130 |
|
| 131 |
history.append((message, assistant_reply, "You", "P-ALPLE", sessions[api_key]["avatar"], ASSISTANT_PIC_PATH))
|
| 132 |
sessions[api_key]["history"] = history
|