Black Goku commited on
Update app.py
Browse files
app.py
CHANGED
|
@@ -148,7 +148,7 @@ class ChatRequest(BaseModel):
|
|
| 148 |
# App
|
| 149 |
# ---------------------------------------------------------------------------
|
| 150 |
|
| 151 |
-
app = FastAPI(title="Yappy API", version="3.0.
|
| 152 |
|
| 153 |
app.add_middleware(
|
| 154 |
CORSMiddleware,
|
|
@@ -301,11 +301,13 @@ def _generate_stream(mode: str, history: List[HistoryTurn], user_message: str, p
|
|
| 301 |
except HfHubHTTPError as e:
|
| 302 |
status = getattr(e.response, "status_code", None) if hasattr(e, "response") else None
|
| 303 |
error_text = str(e).lower()
|
|
|
|
| 304 |
if status == 503 or "loading" in error_text:
|
| 305 |
yield {"event": "token", "data": "Give me a few seconds to wake up properly and try that again."}
|
| 306 |
else:
|
| 307 |
yield {"event": "token", "data": "I had a hiccup processing that. Try sending it again."}
|
| 308 |
-
except Exception:
|
|
|
|
| 309 |
yield {"event": "token", "data": "Something went sideways on my end. Try sending that again."}
|
| 310 |
|
| 311 |
yield {"event": "done", "data": ""}
|
|
|
|
| 148 |
# App
|
| 149 |
# ---------------------------------------------------------------------------
|
| 150 |
|
| 151 |
+
app = FastAPI(title="Yappy API", version="3.0.1")
|
| 152 |
|
| 153 |
app.add_middleware(
|
| 154 |
CORSMiddleware,
|
|
|
|
| 301 |
except HfHubHTTPError as e:
|
| 302 |
status = getattr(e.response, "status_code", None) if hasattr(e, "response") else None
|
| 303 |
error_text = str(e).lower()
|
| 304 |
+
print(f"[Yappy] HfHubHTTPError - status={status} error={e}")
|
| 305 |
if status == 503 or "loading" in error_text:
|
| 306 |
yield {"event": "token", "data": "Give me a few seconds to wake up properly and try that again."}
|
| 307 |
else:
|
| 308 |
yield {"event": "token", "data": "I had a hiccup processing that. Try sending it again."}
|
| 309 |
+
except Exception as e:
|
| 310 |
+
print(f"[Yappy] Unexpected error in _generate_stream: {type(e).__name__}: {e}")
|
| 311 |
yield {"event": "token", "data": "Something went sideways on my end. Try sending that again."}
|
| 312 |
|
| 313 |
yield {"event": "done", "data": ""}
|