Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -94,7 +94,7 @@ def extract_json_from_answer(answer, image_analysis):
|
|
94 |
end_idx = answer.rfind('}')
|
95 |
if start_idx != -1 and end_idx != 0:
|
96 |
json_str = answer[start_idx:end_idx]
|
97 |
-
json_str += f",image_analysis: ['prediction': {image_analysis['prediction']}, 'confidence': {image_analysis['confidence']}%.]"
|
98 |
return json.loads(json_str)
|
99 |
except (json.JSONDecodeError, ValueError):
|
100 |
logger.error("Failed to parse JSON from response")
|
@@ -208,10 +208,10 @@ def gradio_interface(patient_info, image):
|
|
208 |
raise ValueError("Invalid response structure from LLM")
|
209 |
|
210 |
# Extract and clean JSON from the response
|
211 |
-
json_data = extract_json_from_answer(llm_response['data']['answer'], image_analysis)
|
212 |
logger.info(f"llm_response: {llm_response}")
|
213 |
logger.info(f"llm_response[data]: {llm_response['data']}")
|
214 |
logger.info(f"llm_response[data][answer]: {llm_response['data']['answer']}")
|
|
|
215 |
return json.dumps(json_data, indent=2)
|
216 |
|
217 |
except Exception as e:
|
|
|
94 |
end_idx = answer.rfind('}')
|
95 |
if start_idx != -1 and end_idx != 0:
|
96 |
json_str = answer[start_idx:end_idx]
|
97 |
+
json_str += f",'image_analysis': ['prediction': {image_analysis['prediction']}, 'confidence': {image_analysis['confidence']}%.]"
|
98 |
return json.loads(json_str)
|
99 |
except (json.JSONDecodeError, ValueError):
|
100 |
logger.error("Failed to parse JSON from response")
|
|
|
208 |
raise ValueError("Invalid response structure from LLM")
|
209 |
|
210 |
# Extract and clean JSON from the response
|
|
|
211 |
logger.info(f"llm_response: {llm_response}")
|
212 |
logger.info(f"llm_response[data]: {llm_response['data']}")
|
213 |
logger.info(f"llm_response[data][answer]: {llm_response['data']['answer']}")
|
214 |
+
json_data = extract_json_from_answer(llm_response['data']['answer'], image_analysis)
|
215 |
return json.dumps(json_data, indent=2)
|
216 |
|
217 |
except Exception as e:
|