Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -104,16 +104,15 @@ def fetch_advanced_analysis(query, msg):
|
|
104 |
|
105 |
def parse_analysis(analysis_message):
|
106 |
try:
|
107 |
-
# Find the starting point of the JSON string
|
108 |
start = analysis_message.find('{')
|
109 |
-
|
110 |
-
|
111 |
-
json_str = analysis_message[start:]
|
112 |
-
#
|
113 |
analysis_data = json.loads(json_str)
|
114 |
return analysis_data
|
115 |
else:
|
116 |
-
return {"error": "JSON data not found in the response"}
|
117 |
except json.JSONDecodeError as e:
|
118 |
return {"error": "Failed to decode JSON", "details": str(e)}
|
119 |
|
|
|
104 |
|
105 |
def parse_analysis(analysis_message):
|
106 |
try:
|
|
|
107 |
start = analysis_message.find('{')
|
108 |
+
end = analysis_message.rfind('}') + 1 # Find the last '}' and include it
|
109 |
+
if start != -1 and end != -1:
|
110 |
+
json_str = analysis_message[start:end]
|
111 |
+
print("Debug JSON String:", json_str) # Continue to use this for debugging
|
112 |
analysis_data = json.loads(json_str)
|
113 |
return analysis_data
|
114 |
else:
|
115 |
+
return {"error": "Valid JSON data not found in the response"}
|
116 |
except json.JSONDecodeError as e:
|
117 |
return {"error": "Failed to decode JSON", "details": str(e)}
|
118 |
|