pgurazada1 commited on
Commit
fb872b2
·
verified ·
1 Parent(s): 3a811ca

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +13 -0
app.py CHANGED
@@ -90,6 +90,8 @@ def text_extractor(state: State):
90
  }
91
  ]
92
 
 
 
93
 
94
  response = client.chat.completions.create(
95
  model='gpt-4o-mini',
@@ -99,6 +101,8 @@ def text_extractor(state: State):
99
 
100
  extracted_text = response.choices[0].message.content
101
 
 
 
102
  return {'extracted_text': extracted_text}
103
 
104
  def categorizer(state: State):
@@ -113,6 +117,8 @@ def categorizer(state: State):
113
  Do not output anything except the above fields in your JSON output.
114
  Do not delimit the JSON with any extra tags (e.g., ``` or ```JSON).
115
  """
 
 
116
 
117
  categorization_prompt = [
118
  SystemMessage(content=categorization_system_message),
@@ -126,6 +132,9 @@ def categorizer(state: State):
126
 
127
  def verifier(state: State):
128
 
 
 
 
129
  for document in company_policy_document:
130
  if document.page_content.find(f'{type_of_expense}') != -1:
131
  relevant_company_policy = document.page_content
@@ -153,6 +162,8 @@ def verifier(state: State):
153
 
154
  def estimator(state: State):
155
 
 
 
156
  total_bill = 0
157
  total_taxes_and_charges = 0
158
 
@@ -170,6 +181,8 @@ def estimator(state: State):
170
 
171
 
172
  def formatter(state: State):
 
 
173
  final_output_system_message = """
174
  You are an expert accountant tasked to generate the expense claim report.
175
  Generate the expense claim report based on the calculated total amount to be reimbursed and other details available to you.
 
90
  }
91
  ]
92
 
93
+ print("I have access to the Open AI API for text extraction.")
94
+ print("I need to format the input image in the Open AI format")
95
 
96
  response = client.chat.completions.create(
97
  model='gpt-4o-mini',
 
101
 
102
  extracted_text = response.choices[0].message.content
103
 
104
+ print("Extracted text from the input image")
105
+
106
  return {'extracted_text': extracted_text}
107
 
108
  def categorizer(state: State):
 
117
  Do not output anything except the above fields in your JSON output.
118
  Do not delimit the JSON with any extra tags (e.g., ``` or ```JSON).
119
  """
120
+
121
+ print("Categorizing items in the input text to one of: Alcoholic Drinks, Non-Alcoholic Drinks and Food.")
122
 
123
  categorization_prompt = [
124
  SystemMessage(content=categorization_system_message),
 
132
 
133
  def verifier(state: State):
134
 
135
+ print("I now have to retrieve relevant sections of the company policy to exclude items that are not reimbursable.")
136
+ print("I will use the search tool to execute this step.")
137
+
138
  for document in company_policy_document:
139
  if document.page_content.find(f'{type_of_expense}') != -1:
140
  relevant_company_policy = document.page_content
 
162
 
163
  def estimator(state: State):
164
 
165
+ print("Calculating the revised total amount and taxes")
166
+
167
  total_bill = 0
168
  total_taxes_and_charges = 0
169
 
 
181
 
182
 
183
  def formatter(state: State):
184
+ print("Formatting the output into a markdown file")
185
+
186
  final_output_system_message = """
187
  You are an expert accountant tasked to generate the expense claim report.
188
  Generate the expense claim report based on the calculated total amount to be reimbursed and other details available to you.