Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -140,7 +140,7 @@ class OCRProcessor:
|
|
140 |
base64_url = f"data:image/jpeg;base64,{encoded_image}"
|
141 |
ocr_response = self._call_ocr_api({"type": "image_url", "image_url": base64_url})
|
142 |
markdown = self._extract_markdown(ocr_response)
|
143 |
-
|
144 |
chat_response = self._call_chat_complete(
|
145 |
model="pixtral-12b-latest",
|
146 |
messages=[{
|
@@ -156,12 +156,12 @@ class OCRProcessor:
|
|
156 |
response_format={"type": "json_object"},
|
157 |
temperature=0
|
158 |
)
|
159 |
-
|
160 |
# Ensure the response is a dictionary
|
161 |
response_content = chat_response.choices[0].message.content
|
162 |
if isinstance(response_content, list):
|
163 |
response_content = response_content[0] if response_content else "{}"
|
164 |
-
|
165 |
content = json.loads(response_content)
|
166 |
return self._format_structured_response(temp_path, content)
|
167 |
except Exception as e:
|
|
|
140 |
base64_url = f"data:image/jpeg;base64,{encoded_image}"
|
141 |
ocr_response = self._call_ocr_api({"type": "image_url", "image_url": base64_url})
|
142 |
markdown = self._extract_markdown(ocr_response)
|
143 |
+
|
144 |
chat_response = self._call_chat_complete(
|
145 |
model="pixtral-12b-latest",
|
146 |
messages=[{
|
|
|
156 |
response_format={"type": "json_object"},
|
157 |
temperature=0
|
158 |
)
|
159 |
+
|
160 |
# Ensure the response is a dictionary
|
161 |
response_content = chat_response.choices[0].message.content
|
162 |
if isinstance(response_content, list):
|
163 |
response_content = response_content[0] if response_content else "{}"
|
164 |
+
|
165 |
content = json.loads(response_content)
|
166 |
return self._format_structured_response(temp_path, content)
|
167 |
except Exception as e:
|