Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -12,8 +12,7 @@ import traceback
|
|
| 12 |
# ==============================================================
|
| 13 |
# API Configuration - Add your key here
|
| 14 |
# ==============================================================
|
| 15 |
-
GEMINI_API_KEY = "AIzaSyDgNzVud08vXVrvFb5Mz0bHX8vBQ1LihNs"
|
| 16 |
-
|
| 17 |
# ==============================================================
|
| 18 |
# Enhanced extraction prompt with better instructions
|
| 19 |
# ==============================================================
|
|
@@ -38,16 +37,16 @@ Extract and structure the data as valid JSON only (no markdown, no commentary):
|
|
| 38 |
"inventories": {
|
| 39 |
"items": [
|
| 40 |
{
|
| 41 |
-
"quantityShipped": number
|
| 42 |
"inventoryUnits": string | null,
|
| 43 |
"pcs": number | null,
|
| 44 |
"productName": string | null,
|
| 45 |
"productCode": string | null,
|
| 46 |
"product": {
|
| 47 |
-
"category":
|
| 48 |
"defaultUnits": string | null,
|
| 49 |
-
"unit":
|
| 50 |
-
"pcs":
|
| 51 |
"mbf": number | null,
|
| 52 |
"sf": number | null,
|
| 53 |
"pcsHeight": number | null,
|
|
@@ -63,13 +62,14 @@ Extract and structure the data as valid JSON only (no markdown, no commentary):
|
|
| 63 |
EXTRACTION RULES:
|
| 64 |
1. Extract ALL product line items - create one inventory item per product
|
| 65 |
2. Parse dimensions: "2X6X14" → pcsHeight=2, pcsWidth=6, pcsLength=14
|
| 66 |
-
3.
|
| 67 |
-
4.
|
| 68 |
-
5.
|
| 69 |
-
6.
|
| 70 |
-
7.
|
| 71 |
-
8.
|
| 72 |
-
9.
|
|
|
|
| 73 |
|
| 74 |
Return ONLY valid JSON matching this exact structure."""
|
| 75 |
|
|
|
|
| 12 |
# ==============================================================
|
| 13 |
# API Configuration - Add your key here
|
| 14 |
# ==============================================================
|
| 15 |
+
GEMINI_API_KEY = "AIzaSyDgNzVud08vXVrvFb5Mz0bHX8vBQ1LihNs"
|
|
|
|
| 16 |
# ==============================================================
|
| 17 |
# Enhanced extraction prompt with better instructions
|
| 18 |
# ==============================================================
|
|
|
|
| 37 |
"inventories": {
|
| 38 |
"items": [
|
| 39 |
{
|
| 40 |
+
"quantityShipped": "Quantity as number, no of packages",
|
| 41 |
"inventoryUnits": string | null,
|
| 42 |
"pcs": number | null,
|
| 43 |
"productName": string | null,
|
| 44 |
"productCode": string | null,
|
| 45 |
"product": {
|
| 46 |
+
"category": "Product category (OSB/Lumber/etc)",
|
| 47 |
"defaultUnits": string | null,
|
| 48 |
+
"unit": "Unit type from document (MBF, FBM, SF, UNIT etc.)",
|
| 49 |
+
"pcs": "pcs": "Pieces per unit",
|
| 50 |
"mbf": number | null,
|
| 51 |
"sf": number | null,
|
| 52 |
"pcsHeight": number | null,
|
|
|
|
| 62 |
EXTRACTION RULES:
|
| 63 |
1. Extract ALL product line items - create one inventory item per product
|
| 64 |
2. Parse dimensions: "2X6X14" → pcsHeight=2, pcsWidth=6, pcsLength=14
|
| 65 |
+
3. BF = totalQuantity
|
| 66 |
+
4. Convert BF to MBF: BF ÷ 1000
|
| 67 |
+
5. customFields format: "Key||Value" (e.g., "Mill||Tolko")
|
| 68 |
+
6. Look for: PO numbers, shipping info, quantities, product codes, dimensions
|
| 69 |
+
7. Check headers, footers, stamps, handwritten notes, and table cells
|
| 70 |
+
8. If multiple documents, consolidate all items into one JSON
|
| 71 |
+
9. Return null for missing fields
|
| 72 |
+
10.attachments should list all provided filenames
|
| 73 |
|
| 74 |
Return ONLY valid JSON matching this exact structure."""
|
| 75 |
|