Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -17,67 +17,10 @@ logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(
|
|
| 17 |
logger = logging.getLogger(__name__)
|
| 18 |
|
| 19 |
# Email and database configuration
|
| 20 |
-
DB_CONFIG =
|
| 21 |
-
'host': '0.tcp.in.ngrok.io',
|
| 22 |
-
'port': 13890,
|
| 23 |
-
'user': 'root',
|
| 24 |
-
'password': '',
|
| 25 |
-
'database': 'shipment_details'
|
| 26 |
-
}
|
| 27 |
-
|
| 28 |
-
output_format = {
|
| 29 |
-
"origin": None,
|
| 30 |
-
"destination": None,
|
| 31 |
-
"expected_shipment_datetime": None,
|
| 32 |
-
"types_of_service": None,
|
| 33 |
-
"warehouse": None,
|
| 34 |
-
"description": None,
|
| 35 |
-
"quantities": None,
|
| 36 |
-
"carrier_details": None
|
| 37 |
-
}
|
| 38 |
|
| 39 |
# System prompt for LLM
|
| 40 |
-
prompt =
|
| 41 |
-
System prompt: You will be provided with an email containing shipment details. Your task is to extract specific information based on the given instructions.
|
| 42 |
-
|
| 43 |
-
Instructions:
|
| 44 |
-
1. The input email may contain irrelevant information. Focus only on extracting details about future shipments.
|
| 45 |
-
2. The output should be in JSON format with all values to use only double quotes. If a type of information is not found, it should be marked as null.
|
| 46 |
-
3. Extract the following information:
|
| 47 |
-
- origin: The origin location of the consignment.
|
| 48 |
-
- destination: The destination location of the consignment.
|
| 49 |
-
- expected_shipment_datetime: The expected date and time of delivery to the warehouse (format: yyyy-mm-dd hh:mm:ss).
|
| 50 |
-
- types_of_service: The type of service (AIR, LCL, FCL).
|
| 51 |
-
- warehouse: The name of the warehouse.
|
| 52 |
-
- description: A brief description of the email (ASN).
|
| 53 |
-
- quantities: The number of items in the shipment.
|
| 54 |
-
- carrier_details: The details of the carrier.
|
| 55 |
-
4. The output extracted information must be in this format:
|
| 56 |
-
{{
|
| 57 |
-
"origin": "",
|
| 58 |
-
"destination": "",
|
| 59 |
-
"expected_shipment_datetime": "",
|
| 60 |
-
"types_of_service": "",
|
| 61 |
-
"warehouse": "",
|
| 62 |
-
"description": "",
|
| 63 |
-
"quantities": "",
|
| 64 |
-
"carrier_details": ""
|
| 65 |
-
}}
|
| 66 |
-
|
| 67 |
-
Examples:
|
| 68 |
-
1. Email: We are pleased to inform you of an upcoming shipment originating from Hamburg...
|
| 69 |
-
Extracted Information:
|
| 70 |
-
origin: Hamburg,
|
| 71 |
-
destination: New York,
|
| 72 |
-
expected_shipment_datetime: 2024-08-15 00:00:00,
|
| 73 |
-
types_of_service: AIR,
|
| 74 |
-
warehouse: Sky Logistics,
|
| 75 |
-
description: We are pleased to inform you of an upcoming shipment...
|
| 76 |
-
quantities: 200 units,
|
| 77 |
-
carrier_details: Sky Logistics
|
| 78 |
-
|
| 79 |
-
Output: {output_format}
|
| 80 |
-
"""
|
| 81 |
|
| 82 |
# Function to insert extracted shipment details into MySQL database
|
| 83 |
def insert_data(extracted_details):
|
|
|
|
| 17 |
logger = logging.getLogger(__name__)
|
| 18 |
|
| 19 |
# Email and database configuration
|
| 20 |
+
DB_CONFIG = os.getenv('db')
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 21 |
|
| 22 |
# System prompt for LLM
|
| 23 |
+
prompt = os.getenv('prompt')
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 24 |
|
| 25 |
# Function to insert extracted shipment details into MySQL database
|
| 26 |
def insert_data(extracted_details):
|