Spaces:
Running
Running
Update gen.py
Browse files
gen.py
CHANGED
|
@@ -709,11 +709,16 @@ async def generate_text(
|
|
| 709 |
if not line:
|
| 710 |
yield "\n", chosen_model
|
| 711 |
continue
|
| 712 |
-
if
|
| 713 |
-
|
| 714 |
-
|
| 715 |
-
|
| 716 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 717 |
|
| 718 |
yield line + "\n", chosen_model
|
| 719 |
|
|
|
|
| 709 |
if not line:
|
| 710 |
yield "\n", chosen_model
|
| 711 |
continue
|
| 712 |
+
if line.startswith("event: error"):
|
| 713 |
+
fallback()
|
| 714 |
+
|
| 715 |
+
if line.startswith("data:"):
|
| 716 |
+
try:
|
| 717 |
+
obj = json.loads(line[5:].strip())
|
| 718 |
+
if isinstance(obj, dict) and "error" in obj and isinstance(obj["error"], dict):
|
| 719 |
+
fallback()
|
| 720 |
+
except:
|
| 721 |
+
pass
|
| 722 |
|
| 723 |
yield line + "\n", chosen_model
|
| 724 |
|