TensorVizion commited on
Commit
866f975
·
verified ·
1 Parent(s): 4b61207

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -7
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
- output_text = response.choices[0].message.content.strip()
44
 
45
- # Fallback: Sometimes models still wrap JSON in markdown backticks (```json ...
46
- ```)
47
- # This regex strips the markdown so the json.loads() doesn't crash
48
- json_match = re.search(r'```json\n(.*?)\n```', output_text, re.DOTALL)
49
- if json_match:
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)