Update app.py
Browse files
app.py
CHANGED
|
@@ -40,14 +40,13 @@ def extract_data(raw_text, fields_to_extract):
|
|
| 40 |
temperature=0.1, # Low temperature for more deterministic/factual data extraction
|
| 41 |
)
|
| 42 |
|
| 43 |
-
|
| 44 |
|
| 45 |
-
# Fallback:
|
| 46 |
-
|
| 47 |
-
|
| 48 |
-
|
| 49 |
-
|
| 50 |
-
output_text = json_match.group(1)
|
| 51 |
|
| 52 |
# Parse the text into an actual JSON dictionary for the Gradio UI
|
| 53 |
structured_data = json.loads(output_text)
|
|
|
|
| 40 |
temperature=0.1, # Low temperature for more deterministic/factual data extraction
|
| 41 |
)
|
| 42 |
|
| 43 |
+
output_text = response.choices[0].message.content.strip()
|
| 44 |
|
| 45 |
+
# Fallback: Strip markdown code blocks if the model adds them
|
| 46 |
+
# This prevents the json parse step from crashing
|
| 47 |
+
json_match = re.search(r'
|
| 48 |
+
http://googleusercontent.com/immersive_entry_chip/0
|
| 49 |
+
|
|
|
|
| 50 |
|
| 51 |
# Parse the text into an actual JSON dictionary for the Gradio UI
|
| 52 |
structured_data = json.loads(output_text)
|