api.py sherika
Browse files- utils/api.py +5 -1
utils/api.py
CHANGED
|
@@ -337,7 +337,11 @@ def chat_ai(query: str, lesson_id: int, level_slug: str, history=None) -> str:
|
|
| 337 |
"history": history or [],
|
| 338 |
}
|
| 339 |
try:
|
| 340 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 341 |
return d.get("answer", "")
|
| 342 |
except Exception as e:
|
| 343 |
return f"(chat failed: {e})"
|
|
|
|
| 337 |
"history": history or [],
|
| 338 |
}
|
| 339 |
try:
|
| 340 |
+
# Force the full path without relying on _prefixes
|
| 341 |
+
url = f"{BACKEND}/chat" # make sure BACKEND has no trailing slash
|
| 342 |
+
r = _session.post(url, json=payload, timeout=DEFAULT_TIMEOUT)
|
| 343 |
+
r.raise_for_status()
|
| 344 |
+
d = r.json()
|
| 345 |
return d.get("answer", "")
|
| 346 |
except Exception as e:
|
| 347 |
return f"(chat failed: {e})"
|