Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -282,7 +282,20 @@ if ticker_user!="":
|
|
| 282 |
|
| 283 |
|
| 284 |
try:
|
| 285 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 286 |
st.success("JSON parsed successfully!")
|
| 287 |
st.write(res["output_text"]["stock_summary"]["company_name"])
|
| 288 |
st.write(res["output_text"]["stock_summary"]["ticker"])
|
|
|
|
| 282 |
|
| 283 |
|
| 284 |
try:
|
| 285 |
+
raw_text = res["output_text"]
|
| 286 |
+
|
| 287 |
+
# Remove markdown code block delimiters if present
|
| 288 |
+
if raw_text.startswith("```json"):
|
| 289 |
+
raw_text = raw_text[len("```json"):]
|
| 290 |
+
|
| 291 |
+
if raw_text.endswith("```"):
|
| 292 |
+
raw_text = raw_text[:-3]
|
| 293 |
+
|
| 294 |
+
# Also strip leading/trailing whitespace/newlines
|
| 295 |
+
raw_text = raw_text.strip()
|
| 296 |
+
|
| 297 |
+
|
| 298 |
+
data = json.loads(raw_text)
|
| 299 |
st.success("JSON parsed successfully!")
|
| 300 |
st.write(res["output_text"]["stock_summary"]["company_name"])
|
| 301 |
st.write(res["output_text"]["stock_summary"]["ticker"])
|