Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -125,29 +125,69 @@ def get_extraction_prompt(model_choice, txt):
|
|
| 125 |
' "invoice_header": {\n'
|
| 126 |
' "invoice_number": "string or null",\n'
|
| 127 |
' "invoice_date": "string or null",\n'
|
|
|
|
|
|
|
|
|
|
|
|
|
| 128 |
' "supplier_name": "string or null",\n'
|
| 129 |
' "supplier_address": "string or null",\n'
|
|
|
|
|
|
|
|
|
|
| 130 |
' "customer_name": "string or null",\n'
|
| 131 |
' "customer_address": "string or null",\n'
|
| 132 |
-
' "
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 133 |
' "tax_id": "string or null",\n'
|
|
|
|
|
|
|
|
|
|
| 134 |
' "payment_terms": "string or null",\n'
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 135 |
' "total_before_tax": "string or null",\n'
|
| 136 |
' "tax_amount": "string or null",\n'
|
|
|
|
|
|
|
|
|
|
| 137 |
' "total_due": "string or null",\n'
|
| 138 |
-
' "
|
|
|
|
| 139 |
' "due_date": "string or null",\n'
|
| 140 |
-
' "
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 141 |
' },\n'
|
| 142 |
' "line_items": [\n'
|
| 143 |
' {\n'
|
| 144 |
' "item_number": "string or null",\n'
|
|
|
|
|
|
|
|
|
|
| 145 |
' "description": "string or null",\n'
|
| 146 |
' "quantity": "string or null",\n'
|
|
|
|
| 147 |
' "unit_price": "string or null",\n'
|
| 148 |
-
' "
|
| 149 |
' "tax_rate": "string or null",\n'
|
| 150 |
-
' "
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 151 |
' "any_other_line_item_field": "string or null"\n'
|
| 152 |
' }\n'
|
| 153 |
' ]\n'
|
|
@@ -157,6 +197,7 @@ def get_extraction_prompt(model_choice, txt):
|
|
| 157 |
f"{txt}"
|
| 158 |
)
|
| 159 |
|
|
|
|
| 160 |
def extract_invoice_info(model_choice, text):
|
| 161 |
prompt = get_extraction_prompt(model_choice, text)
|
| 162 |
raw = query_llm(model_choice, prompt)
|
|
|
|
| 125 |
' "invoice_header": {\n'
|
| 126 |
' "invoice_number": "string or null",\n'
|
| 127 |
' "invoice_date": "string or null",\n'
|
| 128 |
+
' "order_number": "string or null",\n'
|
| 129 |
+
' "sales_order_number": "string or null",\n'
|
| 130 |
+
' "purchase_order_number": "string or null",\n'
|
| 131 |
+
' "order_date": "string or null",\n'
|
| 132 |
' "supplier_name": "string or null",\n'
|
| 133 |
' "supplier_address": "string or null",\n'
|
| 134 |
+
' "supplier_phone": "string or null",\n'
|
| 135 |
+
' "supplier_email": "string or null",\n'
|
| 136 |
+
' "supplier_tax_id": "string or null",\n'
|
| 137 |
' "customer_name": "string or null",\n'
|
| 138 |
' "customer_address": "string or null",\n'
|
| 139 |
+
' "customer_phone": "string or null",\n'
|
| 140 |
+
' "customer_email": "string or null",\n'
|
| 141 |
+
' "customer_tax_id": "string or null",\n'
|
| 142 |
+
' "ship_to_name": "string or null",\n'
|
| 143 |
+
' "ship_to_address": "string or null",\n'
|
| 144 |
+
' "bill_to_name": "string or null",\n'
|
| 145 |
+
' "bill_to_address": "string or null",\n'
|
| 146 |
' "tax_id": "string or null",\n'
|
| 147 |
+
' "tax_registration_number": "string or null",\n'
|
| 148 |
+
' "vat_number": "string or null",\n'
|
| 149 |
+
' "currency": "string or null",\n'
|
| 150 |
' "payment_terms": "string or null",\n'
|
| 151 |
+
' "payment_method": "string or null",\n'
|
| 152 |
+
' "payment_reference": "string or null",\n'
|
| 153 |
+
' "bank_account_number": "string or null",\n'
|
| 154 |
+
' "iban": "string or null",\n'
|
| 155 |
+
' "swift_code": "string or null",\n'
|
| 156 |
' "total_before_tax": "string or null",\n'
|
| 157 |
' "tax_amount": "string or null",\n'
|
| 158 |
+
' "tax_rate": "string or null",\n'
|
| 159 |
+
' "shipping_charges": "string or null",\n'
|
| 160 |
+
' "discount": "string or null",\n'
|
| 161 |
' "total_due": "string or null",\n'
|
| 162 |
+
' "amount_paid": "string or null",\n'
|
| 163 |
+
' "balance_due": "string or null",\n'
|
| 164 |
' "due_date": "string or null",\n'
|
| 165 |
+
' "invoice_status": "string or null",\n'
|
| 166 |
+
' "reference_number": "string or null",\n'
|
| 167 |
+
' "project_code": "string or null",\n'
|
| 168 |
+
' "department": "string or null",\n'
|
| 169 |
+
' "contact_person": "string or null",\n'
|
| 170 |
+
' "notes": "string or null",\n'
|
| 171 |
+
' "additional_info": "string or null"\n'
|
| 172 |
' },\n'
|
| 173 |
' "line_items": [\n'
|
| 174 |
' {\n'
|
| 175 |
' "item_number": "string or null",\n'
|
| 176 |
+
' "line_number": "string or null",\n'
|
| 177 |
+
' "product_code": "string or null",\n'
|
| 178 |
+
' "sku": "string or null",\n'
|
| 179 |
' "description": "string or null",\n'
|
| 180 |
' "quantity": "string or null",\n'
|
| 181 |
+
' "unit_of_measure": "string or null",\n'
|
| 182 |
' "unit_price": "string or null",\n'
|
| 183 |
+
' "discount": "string or null",\n'
|
| 184 |
' "tax_rate": "string or null",\n'
|
| 185 |
+
' "tax_amount": "string or null",\n'
|
| 186 |
+
' "total_price": "string or null",\n'
|
| 187 |
+
' "delivery_date": "string or null",\n'
|
| 188 |
+
' "gl_code": "string or null",\n'
|
| 189 |
+
' "cost_center": "string or null",\n'
|
| 190 |
+
' "project_code": "string or null",\n'
|
| 191 |
' "any_other_line_item_field": "string or null"\n'
|
| 192 |
' }\n'
|
| 193 |
' ]\n'
|
|
|
|
| 197 |
f"{txt}"
|
| 198 |
)
|
| 199 |
|
| 200 |
+
|
| 201 |
def extract_invoice_info(model_choice, text):
|
| 202 |
prompt = get_extraction_prompt(model_choice, text)
|
| 203 |
raw = query_llm(model_choice, prompt)
|