gopichandra commited on
Commit
2d9d701
·
verified ·
1 Parent(s): 8067975

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -4
app.py CHANGED
@@ -284,7 +284,12 @@ def process_image(image, mode, entry_type, quantity):
284
  else:
285
  attributes["Product name"] = "Unknown"
286
 
287
- return extracted_text, attributes
 
 
 
 
 
288
 
289
  # Function to export edited attributes to Salesforce
290
  def export_to_salesforce(mode, entry_type, quantity, attributes):
@@ -304,9 +309,9 @@ def app():
304
  process_button = gr.Button("Process Image")
305
 
306
  def process_image_and_display(image, mode, entry_type, quantity):
307
- extracted_text, attributes = process_image(image, mode, entry_type, quantity)
308
  attributes_list = [[key, value] for key, value in attributes.items()]
309
- return extracted_text, attributes_list
310
 
311
  process_button.click(process_image_and_display, inputs=[image_input, mode_input, entry_type_input, quantity_input], outputs=[extracted_text_output, attributes_output])
312
 
@@ -318,7 +323,7 @@ def app():
318
  message = export_to_salesforce(mode, entry_type, quantity, attributes)
319
  return message
320
 
321
- export_button.click(export_attributes, inputs=[mode_input, entry_type_input, quantity_input, attributes_output], outputs=result_output)
322
 
323
  with gr.Tab("📊 Salesforce Data Export"):
324
  selected_object_input = gr.Dropdown(label="Select Salesforce Object", choices=["Inventory_Management__c", "Un_Billable__c"], value="Inventory_Management__c")
 
284
  else:
285
  attributes["Product name"] = "Unknown"
286
 
287
+ # Combine extracted text and attributes for display
288
+ combined_text = extracted_text + "\n\nExtracted Attributes:\n"
289
+ for key, value in attributes.items():
290
+ combined_text += f"{key}: {value}\n"
291
+
292
+ return combined_text, attributes
293
 
294
  # Function to export edited attributes to Salesforce
295
  def export_to_salesforce(mode, entry_type, quantity, attributes):
 
309
  process_button = gr.Button("Process Image")
310
 
311
  def process_image_and_display(image, mode, entry_type, quantity):
312
+ combined_text, attributes = process_image(image, mode, entry_type, quantity)
313
  attributes_list = [[key, value] for key, value in attributes.items()]
314
+ return combined_text, attributes_list
315
 
316
  process_button.click(process_image_and_display, inputs=[image_input, mode_input, entry_type_input, quantity_input], outputs=[extracted_text_output, attributes_output])
317
 
 
323
  message = export_to_salesforce(mode, entry_type, quantity, attributes)
324
  return message
325
 
326
+ export_button.click(export_attributes, inputs=[mode_input, entry_type_input, quantity_input, attributes_output], outputs[result_output])
327
 
328
  with gr.Tab("📊 Salesforce Data Export"):
329
  selected_object_input = gr.Dropdown(label="Select Salesforce Object", choices=["Inventory_Management__c", "Un_Billable__c"], value="Inventory_Management__c")