manabb commited on
Commit
ac66e45
·
verified ·
1 Parent(s): 4731096

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +48 -21
app.py CHANGED
@@ -11,9 +11,10 @@ client = OpenAI(api_key=os.getenv("OPENAI_API_KEY"))
11
  #Payment type
12
  manual_payment_type="""
13
  1. Management discouraged the payment thorugh bank.
14
- 2. Advance payment without bank gurantee is not allowed. Require CA approval if given.
15
  3. If payment term is milestone payment, then requirement of bank guarantee against each milestone payment release is to be written.
16
  4. Standard payment term: Payment shall be made within 30 days after receipt and acceptance of material.
 
17
  """
18
 
19
  #=================
@@ -89,7 +90,7 @@ def generate_response(manual, proposal):
89
  return response.choices[0].message.content
90
 
91
  def loop_function(df):
92
- text = "===============================================================\n"
93
  Value_of_proposal = ""
94
  E_file_No=""
95
  Name_of_proposal=""
@@ -105,19 +106,19 @@ def loop_function(df):
105
  continue
106
  if key == "File No.":
107
  E_file_No= f"E-File No: {value}. \n"
108
- text+=E_file_No
109
  continue
110
  if key == "PR No.":
111
  PR_no= f"PR No: {value}. \n"
112
- text+=PR_no
113
  continue
114
  if key == "Name of proposal":
115
  Name_of_proposal= f"Name of the proposal : {value}. \n"
116
- text+=Name_of_proposal
117
- text+="===============================================================\n"
118
  continue
119
  if key == "Value (Rs)":
120
  Value_of_proposal = f"The proposal Value is {value}. \n"
 
121
  continue
122
  if key == "Category":
123
  Category_of_proposal = f"The proposal Category is {value}. \n"
@@ -141,22 +142,32 @@ def loop_function(df):
141
 
142
  if i == 1:
143
  try:
144
- text += "As per proposal, "+key + " : "+value+"\n\n"
 
 
 
145
  rr = generate_response(manual_rules, proposal_details)
146
- text += rr + "\n\n" # FIXED: accumulate
147
- text +="===============================================================\n"
148
  yield text
149
  time.sleep(3)
150
  except Exception as e:
151
  print(f"Error: {e} - skipping row")
152
  continue
153
-
 
 
154
  def check_compliance(file): # FIXED: now streams
155
  if file.name.endswith(".docx"):
156
  df1 = extract_docx_text(file.name)
157
  yield from loop_function(df1) # FIXED: delegate yields
158
  else:
159
  yield "Unsupported file format"
 
 
 
 
 
160
  #================================================Gradio==================
161
 
162
  css = """
@@ -171,6 +182,15 @@ css = """
171
  background-color: #CC0000 !important; /* Darker red on hover */
172
  color: #FFFFFF !important;
173
  }
 
 
 
 
 
 
 
 
 
174
  #compliance-out textarea, #compliance-out .label, #compliance-out label {
175
  color: #FFFFFF !important;
176
  background-color: #000000 !important;
@@ -179,15 +199,22 @@ css = """
179
  """
180
 
181
  with gr.Blocks(css=css) as demo:
182
- with gr.Row():
183
- inp = gr.File( # consistent name
184
- label="Upload Admin File in word i.e. docx format",
185
- file_types=[".docx"],
186
- elem_id="admin-file"
187
- )
188
- run_btn = gr.Button("Check compliance", elem_id="compliance-btn")
189
- out = gr.Textbox(lines=15, label="Compliance Result",elem_id="compliance-out")
190
-
191
- run_btn.click(check_compliance, inputs=inp, outputs=out) # FIXED: inputs=inp
192
-
 
 
 
 
 
 
 
193
  demo.queue().launch()
 
11
  #Payment type
12
  manual_payment_type="""
13
  1. Management discouraged the payment thorugh bank.
14
+ 2. Advance payment without bank gurantee is not allowed. Require Competant Authority approval if given.
15
  3. If payment term is milestone payment, then requirement of bank guarantee against each milestone payment release is to be written.
16
  4. Standard payment term: Payment shall be made within 30 days after receipt and acceptance of material.
17
+ 5. As per NRL GPC or GPC or GPC(general purchase condition) is a complied payment term.
18
  """
19
 
20
  #=================
 
90
  return response.choices[0].message.content
91
 
92
  def loop_function(df):
93
+ text = "<hr>"
94
  Value_of_proposal = ""
95
  E_file_No=""
96
  Name_of_proposal=""
 
106
  continue
107
  if key == "File No.":
108
  E_file_No= f"E-File No: {value}. \n"
109
+ text+="<h2>"+E_file_No+"</h2>"
110
  continue
111
  if key == "PR No.":
112
  PR_no= f"PR No: {value}. \n"
113
+ text+="<h2>"+PR_no+"</h2>"
114
  continue
115
  if key == "Name of proposal":
116
  Name_of_proposal= f"Name of the proposal : {value}. \n"
117
+ text+="<h2>"+Name_of_proposal+"</h2>"
 
118
  continue
119
  if key == "Value (Rs)":
120
  Value_of_proposal = f"The proposal Value is {value}. \n"
121
+ text+="<h2>"+Value_of_proposal+"</h2><hr>"
122
  continue
123
  if key == "Category":
124
  Category_of_proposal = f"The proposal Category is {value}. \n"
 
142
 
143
  if i == 1:
144
  try:
145
+ text += """
146
+ <div style="color: white !important; background: #006400 !important; padding: 10px; font-size: 14px;">
147
+ """
148
+ text += "<h1>As per proposal, "+key + " : "+value+"</h1>"
149
  rr = generate_response(manual_rules, proposal_details)
150
+ text += "<p>"+rr + "</p>"
151
+ text += "</div><hr>"
152
  yield text
153
  time.sleep(3)
154
  except Exception as e:
155
  print(f"Error: {e} - skipping row")
156
  continue
157
+ def loop_function_tech(df):
158
+ #to be prepared
159
+ yield "coming soon"
160
  def check_compliance(file): # FIXED: now streams
161
  if file.name.endswith(".docx"):
162
  df1 = extract_docx_text(file.name)
163
  yield from loop_function(df1) # FIXED: delegate yields
164
  else:
165
  yield "Unsupported file format"
166
+ def check_compliance_tech(file):
167
+ if file.name.endswith(".pdf"):
168
+ yield "Coming Soon"
169
+ else:
170
+ yield "Unsupported file format"
171
  #================================================Gradio==================
172
 
173
  css = """
 
182
  background-color: #CC0000 !important; /* Darker red on hover */
183
  color: #FFFFFF !important;
184
  }
185
+ #compliance-btn-tech {
186
+ color: #FFFFFF !important;
187
+ background-color: green !important; /* Red background */
188
+ font-size: 16px !important;
189
+ }
190
+ #compliance-btn-tech:hover {
191
+ background-color: #006400 !important; /* Darker red on hover */
192
+ color: #FFFFFF !important;
193
+ }
194
  #compliance-out textarea, #compliance-out .label, #compliance-out label {
195
  color: #FFFFFF !important;
196
  background-color: #000000 !important;
 
199
  """
200
 
201
  with gr.Blocks(css=css) as demo:
202
+ with gr.Tabs(elem_id="main-tabs"):
203
+ with gr.TabItem("Compliance Check of Arohan Admin File"):
204
+ with gr.Row():
205
+ inp = gr.File(
206
+ label="Upload Admin File in word i.e. docx format",
207
+ file_types=[".docx"],
208
+ elem_id="admin-file"
209
+ )
210
+ run_btn = gr.Button("Check compliance", elem_id="compliance-btn")
211
+ out = gr.HTML(label="Compliance Result")
212
+ #out = gr.Textbox(lines=15, label="Compliance Result",elem_id="compliance-out")
213
+ run_btn.click(check_compliance, inputs=inp, outputs=out)
214
+ with gr.TabItem("Compliance Check of user technical doc"):
215
+ gr.HTML("""
216
+ <div style="color: white; background: black; padding: 20px; text-align: center; font-size: 24px;">
217
+ 🚧 Coming Soon 🚧
218
+ </div>"""
219
+ )
220
  demo.queue().launch()