Spaces:
Sleeping
Sleeping
Commit Β·
8403c48
1
Parent(s): 4e47e07
fix: handle None values in build_system_context and improve favicon response
Browse files
llm.py
CHANGED
|
@@ -45,6 +45,12 @@ def build_system_context(
|
|
| 45 |
whatif: dict,
|
| 46 |
) -> str:
|
| 47 |
"""Build structured context string from student analysis data."""
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 48 |
|
| 49 |
# ββ Student Profile ββ
|
| 50 |
student_lines = [
|
|
|
|
| 45 |
whatif: dict,
|
| 46 |
) -> str:
|
| 47 |
"""Build structured context string from student analysis data."""
|
| 48 |
+
|
| 49 |
+
# Guard against None values
|
| 50 |
+
student_data = student_data or {}
|
| 51 |
+
prediction = prediction or {}
|
| 52 |
+
explanation = explanation or {}
|
| 53 |
+
whatif = whatif or {}
|
| 54 |
|
| 55 |
# ββ Student Profile ββ
|
| 56 |
student_lines = [
|
main.py
CHANGED
|
@@ -506,7 +506,11 @@ async def read_index():
|
|
| 506 |
# 3. Handle favicon if needed
|
| 507 |
@app.get("/favicon.ico", include_in_schema=False)
|
| 508 |
async def favicon():
|
| 509 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 510 |
|
| 511 |
if __name__ == "__main__":
|
| 512 |
import uvicorn
|
|
|
|
| 506 |
# 3. Handle favicon if needed
|
| 507 |
@app.get("/favicon.ico", include_in_schema=False)
|
| 508 |
async def favicon():
|
| 509 |
+
# Return 204 No Content if favicon doesn't exist to avoid 500 errors
|
| 510 |
+
if os.path.exists("favicon.ico"):
|
| 511 |
+
return FileResponse("favicon.ico")
|
| 512 |
+
from fastapi.responses import Response
|
| 513 |
+
return Response(status_code=204)
|
| 514 |
|
| 515 |
if __name__ == "__main__":
|
| 516 |
import uvicorn
|
script.js
CHANGED
|
@@ -1128,7 +1128,7 @@ async function initializeChat() {
|
|
| 1128 |
method: 'POST',
|
| 1129 |
headers: { 'Content-Type': 'application/json' },
|
| 1130 |
body: JSON.stringify({
|
| 1131 |
-
|
| 1132 |
prediction: currentPrediction,
|
| 1133 |
explanation: currentExplanation,
|
| 1134 |
whatif: currentWhatIf || {}
|
|
|
|
| 1128 |
method: 'POST',
|
| 1129 |
headers: { 'Content-Type': 'application/json' },
|
| 1130 |
body: JSON.stringify({
|
| 1131 |
+
patient_data: formData,
|
| 1132 |
prediction: currentPrediction,
|
| 1133 |
explanation: currentExplanation,
|
| 1134 |
whatif: currentWhatIf || {}
|