Spaces:
Build error
Build error
Extract the string content from the LLM response object before passing it to `format_response_for_user`, and ensure it is a dictionary.
Browse files109 unmodified lines110111112113114115116117118119120109 unmodified lines# Call LLMresponse = llm.complete(prompt)raw = responseif isinstance(raw, str):try:raw = json.loads(raw)except Exception:# If not JSON, wrap in a dict or handle gracefullyraw = {"diagnoses": [], "confidences": [], "follow_up": raw}assistant_msg = format_response_for_user(raw)history = history + [{"role": "assistant", "content": assistant_msg}]109 unmodified lines110111112113114115116117118119120121122123124125109 unmodified lines# Call LLMresponse = llm.complete(prompt)raw = response# Extract text from CompletionResponse if neededif hasattr(raw, "text"):raw = raw.textelif hasattr(raw, "content"):raw = raw.content# Now ensure it's a dictif isinstance(raw, str):try:raw = json.loads(raw)except Exception:raw = {"diagnoses": [], "confidences": [], "follow_up": raw}assistant_msg = format_response_for_user(raw)history = history + [{"role": "assistant", "content": assistant_msg}]
app.py+6-1