Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -119,7 +119,7 @@ def extract_invoice_data(file_data, content_type, json_schema):
|
|
| 119 |
logger.error(f"Error converting PDF to image: {e}")
|
| 120 |
return {"error": "Failed to process PDF"}, None
|
| 121 |
|
| 122 |
-
|
| 123 |
# Handle direct image files
|
| 124 |
base64_encoded = base64.b64encode(file_data).decode('utf-8')
|
| 125 |
base64_images.append(f"data:{content_type};base64,{base64_encoded}")
|
|
@@ -146,8 +146,6 @@ def extract_invoice_data(file_data, content_type, json_schema):
|
|
| 146 |
logger.error(f"Error in OpenAI processing: {e}")
|
| 147 |
return {"error": str(e)}, base64_images
|
| 148 |
|
| 149 |
-
else:
|
| 150 |
-
return {"error": f"Unsupported file type: {content_type}"}
|
| 151 |
|
| 152 |
def get_content_type_from_s3(file_key):
|
| 153 |
"""Fetch the content type (MIME type) of a file stored in S3."""
|
|
|
|
| 119 |
logger.error(f"Error converting PDF to image: {e}")
|
| 120 |
return {"error": "Failed to process PDF"}, None
|
| 121 |
|
| 122 |
+
else:
|
| 123 |
# Handle direct image files
|
| 124 |
base64_encoded = base64.b64encode(file_data).decode('utf-8')
|
| 125 |
base64_images.append(f"data:{content_type};base64,{base64_encoded}")
|
|
|
|
| 146 |
logger.error(f"Error in OpenAI processing: {e}")
|
| 147 |
return {"error": str(e)}, base64_images
|
| 148 |
|
|
|
|
|
|
|
| 149 |
|
| 150 |
def get_content_type_from_s3(file_key):
|
| 151 |
"""Fetch the content type (MIME type) of a file stored in S3."""
|