Spaces:
Running
Running
Update server.py
Browse files
server.py
CHANGED
|
@@ -207,7 +207,18 @@ def chat(req: ChatRequest):
|
|
| 207 |
if not line:
|
| 208 |
continue
|
| 209 |
|
| 210 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 211 |
|
| 212 |
token = data.get("content", "")
|
| 213 |
|
|
|
|
| 207 |
if not line:
|
| 208 |
continue
|
| 209 |
|
| 210 |
+
line = line.decode("utf-8").strip()
|
| 211 |
+
|
| 212 |
+
if not line:
|
| 213 |
+
continue
|
| 214 |
+
|
| 215 |
+
if line.startswith("data:"):
|
| 216 |
+
line = line[5:].strip()
|
| 217 |
+
|
| 218 |
+
try:
|
| 219 |
+
data = json.loads(line)
|
| 220 |
+
except Exception:
|
| 221 |
+
continue
|
| 222 |
|
| 223 |
token = data.get("content", "")
|
| 224 |
|