Spaces:
Running
Running
Amamrnaf
commited on
Commit
·
2cf3347
1
Parent(s):
bd3440d
`Update radio button options in PDF processor interface`
Browse files- app.py +1 -1
- dataSchema.py +201 -0
app.py
CHANGED
@@ -28,7 +28,7 @@ demo = gr.Interface(
|
|
28 |
fn=process_pdf,
|
29 |
inputs=[
|
30 |
gr.File(label="Upload PDF"), # File upload input
|
31 |
-
gr.Radio(["
|
32 |
],
|
33 |
outputs="text", # Text output
|
34 |
title="PDF Processor",
|
|
|
28 |
fn=process_pdf,
|
29 |
inputs=[
|
30 |
gr.File(label="Upload PDF"), # File upload input
|
31 |
+
gr.Radio(["Noc_timesheet_resdiential","Noc_timesheet_rotational", "Noc_invoice"], label="Choose an option") # Radio buttons for options
|
32 |
],
|
33 |
outputs="text", # Text output
|
34 |
title="PDF Processor",
|
dataSchema.py
ADDED
@@ -0,0 +1,201 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from pydantic import BaseModel, Field
|
2 |
+
from typing import Optional,List
|
3 |
+
|
4 |
+
class Noc_Residential_TimeSheetInformation(BaseModel):
|
5 |
+
"""Details of a timesheet entry."""
|
6 |
+
full_name: str = Field(..., description="Full name of the person.")
|
7 |
+
position_title: str = Field(..., description="Position title of the person.")
|
8 |
+
work_location: str = Field(..., description="Work location of the person.")
|
9 |
+
contractor: str = Field(..., description="Contractor's name.")
|
10 |
+
noc_id: str = Field(..., description="NOC ID of the person.")
|
11 |
+
month_year: str = Field(..., description="Month and year in MM/YYYY format.")
|
12 |
+
|
13 |
+
service_days_onshore: int = Field(0, description="Number of service days onshore.")
|
14 |
+
standby_days_onshore: int = Field(0, description="Number of standby days onshore in Doha.")
|
15 |
+
service_days_offshore: int = Field(0, description="Number of service days offshore.")
|
16 |
+
standby_extended_hitch_days_offshore: int = Field(0, description="Number of standby and extended hitch days offshore.")
|
17 |
+
extended_hitch_days_onshore: int = Field(0, description="Number of extended hitch days onshore for rotational personnel.")
|
18 |
+
service_days_weekend_public_holiday: int = Field(0, description="Number of service days during weekends or public holidays.")
|
19 |
+
per_diem_days: int = Field(0, description="Number of Per Diem days for onshore/offshore rotational personnel.")
|
20 |
+
training_days: int = Field(0, description="Number of training days.")
|
21 |
+
travel_days: int = Field(0, description="Number of travel days.")
|
22 |
+
|
23 |
+
class Noc_Rotational_TimeSheetInformation(BaseModel):
|
24 |
+
"""Details of a timesheet entry."""
|
25 |
+
full_name: str = Field(..., description="Full name of the person.")
|
26 |
+
position_title: str = Field(..., description="Position title of the person.")
|
27 |
+
work_location: str = Field(..., description="Work location of the person.")
|
28 |
+
contractor: str = Field(..., description="Contractor's name.")
|
29 |
+
PO_number: Optional[str] = Field(None,description="Purchase order")
|
30 |
+
noc_id: str = Field(..., description="NOC ID of the person.")
|
31 |
+
month_year: str = Field(..., description="Month and year in MM/YYYY format.")
|
32 |
+
|
33 |
+
service_days_onshore: int = Field(0, description="Number of service days onshore.")
|
34 |
+
standby_days_onshore: int = Field(0, description="Number of standby days onshore in Doha.")
|
35 |
+
service_days_offshore: int = Field(0, description="Number of service days offshore.")
|
36 |
+
service_days_weekend_public_holiday: int = Field(0, description="Number of service days during weekends or public holidays.")
|
37 |
+
standby_extended_hitch_days_offshore: int = Field(0, description="Number of standby and extended hitch days offshore.")
|
38 |
+
extended_hitch_days_onshore: int = Field(0, description="Number of extended hitch days onshore for rotational personnel.")
|
39 |
+
overtime_Hourly_Rate_ONSHORE:int = Field(0,description="number of over time hours onshore (Over 8 hours) ")
|
40 |
+
overtime_Hourly_Rate_OFFSHORE:int = Field(0,description="number of over time hours offshore (Over 12 hours) ")
|
41 |
+
per_diem_days: int = Field(0, description="Number of Per Diem days for onshore/offshore rotational personnel.")
|
42 |
+
training_days: int = Field(0, description="Number of training days.")
|
43 |
+
travel_days: int = Field(0, description="Number of travel days.")
|
44 |
+
|
45 |
+
class Noc_Item_Information(BaseModel):
|
46 |
+
"""Details of each item in the document."""
|
47 |
+
item_number : int = Field(...,description="the number of the item")
|
48 |
+
service_description_code: str = Field(..., description="Service description code for the item.")
|
49 |
+
completion_date: str = Field(..., description="Completion date of the service in DD/MM/YYYY format.")
|
50 |
+
quantity: float = Field(..., description="Quantity of the service or item provided.")
|
51 |
+
unit: str = Field(..., description="Unit of measurement, e.g., Days.")
|
52 |
+
unit_price: float = Field(..., description="Unit price.")
|
53 |
+
net_amount: float = Field(..., description="Total net amount for this item, calculated as quantity * unit price.")
|
54 |
+
service_details: str = Field(..., description="Detailed description of the service provided.")
|
55 |
+
|
56 |
+
class Noc_Document_Information(BaseModel):
|
57 |
+
"""Details of the entire document."""
|
58 |
+
position_title: str = Field(..., description="Position title of the person.")
|
59 |
+
location: Optional[str] = Field(None, description="Location where the service is rendered.")
|
60 |
+
mobilization_date: str = Field(..., description="Mobilization date in DD/MM/YYYY format.")
|
61 |
+
end_date: str = Field(..., description="End date of the contract in DD/MM/YYYY format.")
|
62 |
+
notice_period: Optional[str] = Field(None, description="Notice period for resignation, if applicable")
|
63 |
+
items: List[Noc_Item_Information] = Field(..., description="List of items or services provided in the document.")
|
64 |
+
|
65 |
+
class Noc_items(BaseModel):
|
66 |
+
items: List[Noc_Item_Information] = Field(None, description="List of items or services provided in the document.")
|
67 |
+
|
68 |
+
class Noc_total(BaseModel):
|
69 |
+
"""totals of the invoice"""
|
70 |
+
total_amount_wo_taxes : float = Field(...,description="total amount without taxes")
|
71 |
+
total_net_amount_of_order: float = Field(..., description="total net amount of order.")
|
72 |
+
total_amount_of_order: float = Field(..., description="total amount of order.")
|
73 |
+
|
74 |
+
class Noc_PurchaseOrderInformation(BaseModel):
|
75 |
+
"""Details of a purchase order entry."""
|
76 |
+
purchase_order_number: str = Field(..., description="The unique identifier for the purchase order.")
|
77 |
+
date: str = Field(..., description="Date of the purchase order in DD/MM/YYYY format.")
|
78 |
+
company_name: str = Field(..., description="Name of the company issuing the purchase order.")
|
79 |
+
address: str = Field(..., description="Address of the company issuing the purchase order.")
|
80 |
+
tel: Optional[str] = Field(None, description="Telephone number of the company.")
|
81 |
+
email: Optional[str] = Field(None, description="Email address of the company.")
|
82 |
+
final_shipping_address: Optional[str] = Field(None, description="Final shipping address for the order.")
|
83 |
+
buyer_contact_name: str = Field(..., description="Full name of the buyer contact.")
|
84 |
+
buyer_contact_company: str = Field(..., description="Company name of the buyer contact.")
|
85 |
+
buyer_contact_tel: Optional[str] = Field(None, description="Telephone number of the buyer contact.")
|
86 |
+
buyer_contact_email: Optional[str] = Field(None, description="Email address of the buyer contact.")
|
87 |
+
our_reference: Optional[str] = Field(None, description="under Our reference title.")
|
88 |
+
your_reference: Optional[str] = Field(None, description="under Your reference title.")
|
89 |
+
incoterms: Optional[str] = Field(None, description="Incoterms applicable to the order.")
|
90 |
+
total_value_of_order: str = Field(..., description="Total value of the purchase order.")
|
91 |
+
signature_released_by: str = Field(None, description="Name of the person who released the purchase order.")
|
92 |
+
signature_date: Optional[str] = Field(None, description="Date the order was signed.")
|
93 |
+
|
94 |
+
class Noc_Clauses(BaseModel):
|
95 |
+
Clauses: str = Field(..., description="the contract clauses.")
|
96 |
+
|
97 |
+
|
98 |
+
Noc_Res_timesheet_prompt = """
|
99 |
+
Based on the provided timesheet details, extract the following information:
|
100 |
+
- Full name of the person
|
101 |
+
- Position title of the person
|
102 |
+
- Work location
|
103 |
+
- Contractor's name
|
104 |
+
- NOC ID
|
105 |
+
- Month and year (in MM/YYYY format)
|
106 |
+
And from the bottom table :
|
107 |
+
- Number of service days onshore
|
108 |
+
- Number of standby days onshore in Doha
|
109 |
+
- Number of service days offshore
|
110 |
+
- Number of service days during weekends or public holidays
|
111 |
+
- Number of standby and extended hitch days offshore
|
112 |
+
- Number of extended hitch days onshore for rotational personnel
|
113 |
+
- Number of Per Diem days for onshore/offshore rotational personnel
|
114 |
+
- Number of training days
|
115 |
+
- Number of travel days
|
116 |
+
"""
|
117 |
+
|
118 |
+
Noc_Rot_timesheet_prompt = """
|
119 |
+
Based on the provided timesheet details, extract the following information:
|
120 |
+
- Full name of the person
|
121 |
+
- Position title of the person
|
122 |
+
- Work location
|
123 |
+
- Contractor's name
|
124 |
+
- PO number which is the Purchase order
|
125 |
+
- NOC ID
|
126 |
+
- Month and year (in MM/YYYY format)
|
127 |
+
And from the bottom table :
|
128 |
+
- Number of service days onshore
|
129 |
+
- Number of standby days onshore in Doha
|
130 |
+
- Number of service days offshore
|
131 |
+
- Number of service days during weekends or public holidays
|
132 |
+
- Number of standby and extended hitch days offshore
|
133 |
+
- Number of extended hitch days onshore for rotational personnel
|
134 |
+
- ONSHORE Overtime Hourly Rate (Over 8 hours)
|
135 |
+
- OFFSHORE Overtime Hourly Rate (Over 12 hours)
|
136 |
+
- Number of Per Diem days for onshore/offshore rotational personnel
|
137 |
+
- Number of training days
|
138 |
+
- Number of travel days
|
139 |
+
"""
|
140 |
+
|
141 |
+
invoice_first_page_prompt="""
|
142 |
+
Extract the following details from the provided purchase order document:
|
143 |
+
- Purchase Order Number: The unique identifier for the purchase order.
|
144 |
+
- Date: The date the purchase order was issued (format: DD/MM/YYYY).
|
145 |
+
- Company Name: The name of the company issuing the purchase order.
|
146 |
+
- Address: The address of the company issuing the purchase order.
|
147 |
+
- Telephone Number: The company's telephone number (if provided).
|
148 |
+
- Email: The company's email address (if provided).
|
149 |
+
- Final Shipping Address: The destination shipping address (if specified).
|
150 |
+
- Buyer Contact Name: The full name of the buyer's contact person.
|
151 |
+
- Buyer Contact Company: The company name of the buyer contact.
|
152 |
+
- Buyer Contact Telephone Number: The buyer contact's telephone number (if provided).
|
153 |
+
- Buyer Contact Email: The buyer contact's email address (if provided).
|
154 |
+
- Our Reference: Reference specified under the "Our Reference" section (if present).
|
155 |
+
- Your Reference: Reference specified under the "Your Reference" section (if present).
|
156 |
+
- Incoterms: Any applicable incoterms mentioned in the document (e.g., FOB, CIF).
|
157 |
+
- Total Value of the Order: The total monetary value of the purchase order (include currency).
|
158 |
+
- Signature Released By: The name of the person who authorized or released the purchase order.
|
159 |
+
- Signature Date: The date when the order was signed (format: DD/MM/YYYY).
|
160 |
+
"""
|
161 |
+
|
162 |
+
invoice_item_page1_prompt = """
|
163 |
+
Given the document, extract the following information:
|
164 |
+
- Position Title: The role or title mentioned in the document.
|
165 |
+
- Location: The place where the service is being provided.
|
166 |
+
- Mobilization Date: The date work begins in DD-MM-YYYY format.
|
167 |
+
- End Date: The date the work ends in DD-MM-YYYY format.
|
168 |
+
- Notice Period: The required notice period for resignation or termination.
|
169 |
+
- Items: For each item in the document, provide:
|
170 |
+
- Service Description Code: A code identifying the service.
|
171 |
+
- Completion Date: The date the service was completed in DD-MM-YYYY format.
|
172 |
+
- Quantity: The amount of the item/service provided.
|
173 |
+
- Unit: The unit of measurement (e.g., Days, Hours).
|
174 |
+
- Unit Price: The price per unit.
|
175 |
+
- Net Amount: The total value for the item.
|
176 |
+
- Service Details:A description of the service, which follows the corresponding row for the item.
|
177 |
+
|
178 |
+
"""
|
179 |
+
|
180 |
+
invoice_item_pages_prompt = """
|
181 |
+
Given the document, extract the following information:
|
182 |
+
- Items:
|
183 |
+
- Service Description Code: A code identifying the service.
|
184 |
+
- Completion Date: The date the service was completed in DD-MM-YYYY format.
|
185 |
+
- Quantity: The amount of the item/service provided.
|
186 |
+
- Unit: The unit of measurement (e.g., Days, Hours).
|
187 |
+
- Unit Price: The price per unit.
|
188 |
+
- Net Amount: The total value for the item.
|
189 |
+
- Service Details:A description of the service, which follows the corresponding row for the item.
|
190 |
+
|
191 |
+
"""
|
192 |
+
|
193 |
+
invoice_total_page_prompt = """
|
194 |
+
extract from the document:
|
195 |
+
- Total Amount without taxes.
|
196 |
+
- Total net amount of order.
|
197 |
+
- Total amount of order.
|
198 |
+
"""
|
199 |
+
|
200 |
+
invoice_clauses_page_prompt = """
|
201 |
+
extract from the document the clauses """
|