pgurazada1 commited on
Commit
5e5394f
·
verified ·
1 Parent(s): ce70d88

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -9
app.py CHANGED
@@ -92,9 +92,8 @@ def text_extractor(state: State):
92
  ]
93
 
94
  print("I have access to the Open AI API for text extraction.")
95
- gr.Info("I have access to the Open AI API for text extraction.")
96
  print("I need to format the input image in the Open AI format")
97
- gr.Info("I need to format the input image in the Open AI format")
98
 
99
  response = client.chat.completions.create(
100
  model='gpt-4o-mini',
@@ -105,7 +104,7 @@ def text_extractor(state: State):
105
  extracted_text = response.choices[0].message.content
106
 
107
  print("Extracted text from the input image")
108
- gr.Info("Extracted text from the input image")
109
 
110
  return {'extracted_text': extracted_text}
111
 
@@ -123,7 +122,7 @@ def categorizer(state: State):
123
  """
124
 
125
  print("Categorizing items in the input text to one of: Alcoholic Drinks, Non-Alcoholic Drinks and Food.")
126
- gr.Info("Categorizing items in the input text to one of: Alcoholic Drinks, Non-Alcoholic Drinks and Food.")
127
 
128
  categorization_prompt = [
129
  SystemMessage(content=categorization_system_message),
@@ -138,9 +137,8 @@ def categorizer(state: State):
138
  def verifier(state: State):
139
 
140
  print("I now have to retrieve relevant sections of the company policy to exclude items that are not reimbursable.")
141
- gr.Info("I now have to retrieve relevant sections of the company policy to exclude items that are not reimbursable.")
142
  print("I will use the search tool to execute this step.")
143
- gr.Info("I will use the search tool to execute this step.")
144
 
145
  for document in company_policy_document:
146
  if document.page_content.find(f'{type_of_expense}') != -1:
@@ -170,7 +168,7 @@ def verifier(state: State):
170
  def estimator(state: State):
171
 
172
  print("Calculating the revised total amount and taxes")
173
- gr.Info("Calculating the revised total amount and taxes")
174
 
175
  total_bill = 0
176
  total_taxes_and_charges = 0
@@ -190,7 +188,7 @@ def estimator(state: State):
190
 
191
  def formatter(state: State):
192
  print("Formatting the output into a markdown file")
193
- gr.Info("Formatting the output into a markdown file")
194
 
195
  final_output_system_message = """
196
  You are an expert accountant tasked to generate the expense claim report.
@@ -280,7 +278,7 @@ def claim_generator(input_bill_path, progress=gr.Progress()):
280
  output = chain.invoke({'image_path': input_bill_path})
281
  progress(0.25)
282
 
283
- print("Converting the markdown file to pdf")
284
 
285
  pdf = MarkdownPdf(toc_level=3)
286
 
 
92
  ]
93
 
94
  print("I have access to the Open AI API for text extraction.")
95
+ gr.Info("I have access to the Open AI API for text extraction. I need to format the input image in the Open AI format", duration=2)
96
  print("I need to format the input image in the Open AI format")
 
97
 
98
  response = client.chat.completions.create(
99
  model='gpt-4o-mini',
 
104
  extracted_text = response.choices[0].message.content
105
 
106
  print("Extracted text from the input image")
107
+ gr.Info("Extracted text from the input image", duration=2)
108
 
109
  return {'extracted_text': extracted_text}
110
 
 
122
  """
123
 
124
  print("Categorizing items in the input text to one of: Alcoholic Drinks, Non-Alcoholic Drinks and Food.")
125
+ gr.Info("Categorizing items in the input text to one of: Alcoholic Drinks, Non-Alcoholic Drinks and Food.", duration=1)
126
 
127
  categorization_prompt = [
128
  SystemMessage(content=categorization_system_message),
 
137
  def verifier(state: State):
138
 
139
  print("I now have to retrieve relevant sections of the company policy to exclude items that are not reimbursable.")
140
+ gr.Info("I now have to retrieve relevant sections of the company policy to exclude items that are not reimbursable. I will use the search tool to execute this step", duration=2)
141
  print("I will use the search tool to execute this step.")
 
142
 
143
  for document in company_policy_document:
144
  if document.page_content.find(f'{type_of_expense}') != -1:
 
168
  def estimator(state: State):
169
 
170
  print("Calculating the revised total amount and taxes")
171
+ gr.Info("Calculating the revised total amount and taxes", duration=1)
172
 
173
  total_bill = 0
174
  total_taxes_and_charges = 0
 
188
 
189
  def formatter(state: State):
190
  print("Formatting the output into a markdown file")
191
+ gr.Info("Formatting the output into a markdown file", duration=1)
192
 
193
  final_output_system_message = """
194
  You are an expert accountant tasked to generate the expense claim report.
 
278
  output = chain.invoke({'image_path': input_bill_path})
279
  progress(0.25)
280
 
281
+ gr.Info("Converting the markdown file to pdf", duration=2)
282
 
283
  pdf = MarkdownPdf(toc_level=3)
284