Spaces:
Sleeping
Sleeping
Commit ·
460118a
1
Parent(s): ca0e0dc
Fix UI overflow and refine error message formatting
Browse files- frontend/src/index.css +2 -0
- openrouter_client.py +12 -1
frontend/src/index.css
CHANGED
|
@@ -65,6 +65,8 @@ body {
|
|
| 65 |
border-radius: 1rem;
|
| 66 |
position: relative;
|
| 67 |
animation: fadeIn 0.3s ease-out;
|
|
|
|
|
|
|
| 68 |
}
|
| 69 |
|
| 70 |
@keyframes fadeIn {
|
|
|
|
| 65 |
border-radius: 1rem;
|
| 66 |
position: relative;
|
| 67 |
animation: fadeIn 0.3s ease-out;
|
| 68 |
+
word-break: break-word;
|
| 69 |
+
overflow-wrap: anywhere;
|
| 70 |
}
|
| 71 |
|
| 72 |
@keyframes fadeIn {
|
openrouter_client.py
CHANGED
|
@@ -35,7 +35,18 @@ class OpenRouterClient:
|
|
| 35 |
async with client.stream("POST", self.base_url, headers=headers, json=payload) as response:
|
| 36 |
if response.status_code != 200:
|
| 37 |
error_detail = await response.aread()
|
| 38 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 39 |
return
|
| 40 |
|
| 41 |
async for line in response.aiter_lines():
|
|
|
|
| 35 |
async with client.stream("POST", self.base_url, headers=headers, json=payload) as response:
|
| 36 |
if response.status_code != 200:
|
| 37 |
error_detail = await response.aread()
|
| 38 |
+
try:
|
| 39 |
+
error_json = json.loads(error_detail)
|
| 40 |
+
error_msg = error_json.get("error", {}).get("message", "Unknown error")
|
| 41 |
+
|
| 42 |
+
if response.status_code == 429:
|
| 43 |
+
yield "I apologize, but my premium brain is currently taking a short breather (rate limit reached). Please try again in a few moments."
|
| 44 |
+
elif response.status_code == 401:
|
| 45 |
+
yield "Connection error: API key is invalid or expired."
|
| 46 |
+
else:
|
| 47 |
+
yield f"I'm having a little trouble connecting to my service (Error {response.status_code}: {error_msg}). Please try again soon."
|
| 48 |
+
except:
|
| 49 |
+
yield f"Error: {response.status_code} - Encountered an unexpected response format."
|
| 50 |
return
|
| 51 |
|
| 52 |
async for line in response.aiter_lines():
|