Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -172,7 +172,7 @@ def extract_text_from_file(
|
|
| 172 |
"document": existing_document
|
| 173 |
}
|
| 174 |
# Fetch dynamic schema based on document type
|
| 175 |
-
schema_doc =
|
| 176 |
if not schema_doc:
|
| 177 |
raise ValueError("No schema found for the given document type")
|
| 178 |
|
|
@@ -185,7 +185,7 @@ def extract_text_from_file(
|
|
| 185 |
|
| 186 |
# Extract and parse invoice data
|
| 187 |
file_data, _ = fetch_file_from_s3(file_key)
|
| 188 |
-
extracted_data = extract_invoice_data(file_data, content_type,json_schema)
|
| 189 |
|
| 190 |
# Store extracted data in MongoDB
|
| 191 |
document = {
|
|
|
|
| 172 |
"document": existing_document
|
| 173 |
}
|
| 174 |
# Fetch dynamic schema based on document type
|
| 175 |
+
schema_doc = invoice_collection.find_one({"document_type": document_type})
|
| 176 |
if not schema_doc:
|
| 177 |
raise ValueError("No schema found for the given document type")
|
| 178 |
|
|
|
|
| 185 |
|
| 186 |
# Extract and parse invoice data
|
| 187 |
file_data, _ = fetch_file_from_s3(file_key)
|
| 188 |
+
extracted_data = extract_invoice_data(file_data, content_type, json_schema)
|
| 189 |
|
| 190 |
# Store extracted data in MongoDB
|
| 191 |
document = {
|