qq1023 commited on
Commit
836a370
1 Parent(s): f319991

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +10 -8
app.py CHANGED
@@ -79,7 +79,7 @@ def clear_inputs():
79
 
80
  def clear_outputs(input_file):
81
  if input_file:
82
- return None, None, None, pd.json_normalize({'Processing input...': ''})
83
 
84
 
85
  def extract_text(input_file):
@@ -142,17 +142,19 @@ def parse(category, chatbot):
142
  chain = categories.category_modules[category].chain
143
  yield {"status": "Parsing response..."}
144
  try:
145
- information = chain.output_parser.parse(answer) or {
146
- "Error": "No output"
147
- }
148
  information = information.json() if information else {}
149
  except OutputParserException as e:
150
  information = {
151
- "error": "Unable to parse chatbot output",
152
  "details": str(e),
153
  "output": e.llm_output,
154
  }
155
- yield pd.json_normalize(information)
 
 
 
156
 
157
 
158
  def activate_flags():
@@ -263,7 +265,7 @@ with gr.Blocks(title="Automatic Reimbursement Tool Demo") as page:
263
  interactive=False,
264
  height=240,
265
  )
266
- information = gr.Dataframe(pd.DataFrame({"Extracted information": ["Waiting for input..."]}))
267
 
268
  with gr.Row():
269
  flag_incorrect_button = gr.Button(
@@ -392,4 +394,4 @@ page.queue(
392
  concurrency_count=20,
393
  max_size=1,
394
  )
395
- page.launch(show_api=True, show_error=True, debug=True)
 
79
 
80
  def clear_outputs(input_file):
81
  if input_file:
82
+ return None, None, None, None
83
 
84
 
85
  def extract_text(input_file):
 
142
  chain = categories.category_modules[category].chain
143
  yield {"status": "Parsing response..."}
144
  try:
145
+ information = chain.output_parser.parse(answer)
146
+
147
+
148
  information = information.json() if information else {}
149
  except OutputParserException as e:
150
  information = {
 
151
  "details": str(e),
152
  "output": e.llm_output,
153
  }
154
+ yield information
155
+
156
+
157
+ def activate_flags():
158
 
159
 
160
  def activate_flags():
 
265
  interactive=False,
266
  height=240,
267
  )
268
+ information = gr.JSON(label="Extracted information")
269
 
270
  with gr.Row():
271
  flag_incorrect_button = gr.Button(
 
394
  concurrency_count=20,
395
  max_size=1,
396
  )
397
+ page.launch(show_api=True, show_error=True, debug=True)