Spaces:
Running
Running
json is coming back
Browse files
app.py
CHANGED
@@ -109,19 +109,13 @@ def on_submit(symptoms_text, history):
|
|
109 |
|
110 |
# Call LLM
|
111 |
response = llm.complete(prompt)
|
112 |
-
raw =
|
113 |
-
|
114 |
-
msg = "📡 Raw LLM response received"
|
115 |
-
log.append(msg)
|
116 |
-
print(msg, flush=True)
|
117 |
-
yield history, None, "\n".join(log)
|
118 |
-
|
119 |
-
# Final assistant message
|
120 |
if isinstance(raw, str):
|
121 |
try:
|
122 |
raw = json.loads(raw)
|
123 |
except Exception:
|
124 |
-
|
|
|
125 |
assistant_msg = format_response_for_user(raw)
|
126 |
history = history + [{"role": "assistant", "content": assistant_msg}]
|
127 |
msg = "✅ Final response appended"
|
|
|
109 |
|
110 |
# Call LLM
|
111 |
response = llm.complete(prompt)
|
112 |
+
raw = response
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
113 |
if isinstance(raw, str):
|
114 |
try:
|
115 |
raw = json.loads(raw)
|
116 |
except Exception:
|
117 |
+
# If not JSON, wrap in a dict or handle gracefully
|
118 |
+
raw = {"diagnoses": [], "confidences": [], "follow_up": raw}
|
119 |
assistant_msg = format_response_for_user(raw)
|
120 |
history = history + [{"role": "assistant", "content": assistant_msg}]
|
121 |
msg = "✅ Final response appended"
|