Update pipeline.py
Browse files- pipeline.py +5 -3
pipeline.py
CHANGED
|
@@ -31,14 +31,16 @@ def extract_key_values_with_gemini(raw_text, form_type="pancard_form"):
|
|
| 31 |
You are an intelligent document parser.
|
| 32 |
Given the following document text, extract only these fields: {FORMS[form_type]}.
|
| 33 |
Return strictly as JSON key-value pairs.
|
| 34 |
-
|
| 35 |
Document text:
|
| 36 |
{raw_text}
|
| 37 |
"""
|
| 38 |
-
|
|
|
|
|
|
|
| 39 |
print("Gemini API called successfully ✅")
|
| 40 |
response = model.generate_content(prompt)
|
|
|
|
| 41 |
try:
|
| 42 |
return json.loads(response.text)
|
| 43 |
except Exception:
|
| 44 |
-
return {"raw_output": response.text}
|
|
|
|
| 31 |
You are an intelligent document parser.
|
| 32 |
Given the following document text, extract only these fields: {FORMS[form_type]}.
|
| 33 |
Return strictly as JSON key-value pairs.
|
|
|
|
| 34 |
Document text:
|
| 35 |
{raw_text}
|
| 36 |
"""
|
| 37 |
+
|
| 38 |
+
# Use the supported model
|
| 39 |
+
model = genai.GenerativeModel("models/gemini-2.5-flash")
|
| 40 |
print("Gemini API called successfully ✅")
|
| 41 |
response = model.generate_content(prompt)
|
| 42 |
+
|
| 43 |
try:
|
| 44 |
return json.loads(response.text)
|
| 45 |
except Exception:
|
| 46 |
+
return {"raw_output": response.text}
|