hsienchen commited on
Commit
3c58186
1 Parent(s): 128b53d

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +32 -4
app.py CHANGED
@@ -28,6 +28,23 @@ For example:
28
  """
29
 
30
  txt_display_1 = 'content of the letter: '
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
31
  import os
32
  GOOGLE_API_KEY=os.getenv('GOOGLE_API_KEY')
33
  genai.configure(api_key=GOOGLE_API_KEY)
@@ -52,6 +69,17 @@ def app1_response(img):
52
  response = vis_model.generate_content([txt_prompt_1,img])
53
  return response.text
54
 
 
 
 
 
 
 
 
 
 
 
 
55
  # SMS service ends in March 2024, to restore service @Sinch Simple Text
56
  def send_SMS(resp_text):
57
  url = SMS_URL
@@ -72,8 +100,8 @@ def send_SMS(resp_text):
72
  # gradio block
73
  with gr.Blocks() as app1:
74
  with gr.Column():
75
- gr.Markdown("```for email and/or instruction, paste screenshot here...```")
76
- image_box = gr.Image(type="filepath")
77
  btn1 = gr.Button("generate To-Dos")
78
  out1 = gr.Textbox(label="here are the actionables...")
79
  btn2 = gr.Button("Send to Mobile")
@@ -97,13 +125,13 @@ with gr.Blocks() as app1:
97
  with gr.Blocks() as app2:
98
  with gr.Column():
99
  gr.Markdown("```Stock-Out Shamer, paste ERP Inv screenshot here...```")
100
- image_box = gr.Image(type="filepath")
101
  btn1 = gr.Button("check ROQ")
102
  out1 = gr.Textbox(label="here is the watch list...")
103
  btn2 = gr.Button("send out reminders")
104
  out2 = gr.Textbox(label="response or feed back?")
105
 
106
- btn1.click(fn=app1_response, inputs=[image_box], outputs=out1)
107
  btn2.click(fn=send_SMS, inputs=out1, outputs=out2)
108
 
109
  gr.Markdown("""
 
28
  """
29
 
30
  txt_display_1 = 'content of the letter: '
31
+
32
+
33
+ txt_prompt_2 = """The image contains an inventory stock level table with Item Id, Quantity, ROQ, Item Images, and Contact Phone. For reference, ROQ stands for Replenishment Order Quantity.
34
+ It is for use of reorder, that is, when quantity level is below ROQ, a reorder process will need to take place. Please provide a list of reorder items for all below ROQ. When responding please follow the below formats:
35
+
36
+ ** ROQ ({today's date})**
37
+ Item ID, Shortage (Quantity - ROQ), Contact Phone
38
+ (for all below ROQ items)
39
+
40
+ For example:
41
+ ** ROQ (02/21/2024) **
42
+ #11608, 70 (30-100), 1-858-7331029
43
+ #61785, 5 (5-10), 1-858-1233
44
+
45
+ """
46
+ txt_display_2 = 'today's inventory stock level: '
47
+
48
  import os
49
  GOOGLE_API_KEY=os.getenv('GOOGLE_API_KEY')
50
  genai.configure(api_key=GOOGLE_API_KEY)
 
69
  response = vis_model.generate_content([txt_prompt_1,img])
70
  return response.text
71
 
72
+ def app2_response(img):
73
+ if not img:
74
+ response = txt_model.generate_content(txt_prompt_2)
75
+ return response
76
+
77
+ else:
78
+ img = PIL.Image.open(img)
79
+ response = vis_model.generate_content([txt_prompt_2,img])
80
+ return response.text
81
+
82
+
83
  # SMS service ends in March 2024, to restore service @Sinch Simple Text
84
  def send_SMS(resp_text):
85
  url = SMS_URL
 
100
  # gradio block
101
  with gr.Blocks() as app1:
102
  with gr.Column():
103
+ gr.Markdown("```for email and/or assigment descriptions, paste screenshot here...```")
104
+ image_box = gr.Image(label="email screen", type="filepath")
105
  btn1 = gr.Button("generate To-Dos")
106
  out1 = gr.Textbox(label="here are the actionables...")
107
  btn2 = gr.Button("Send to Mobile")
 
125
  with gr.Blocks() as app2:
126
  with gr.Column():
127
  gr.Markdown("```Stock-Out Shamer, paste ERP Inv screenshot here...```")
128
+ image_box = gr.Image(label="ERP/Inventory screen",type="filepath")
129
  btn1 = gr.Button("check ROQ")
130
  out1 = gr.Textbox(label="here is the watch list...")
131
  btn2 = gr.Button("send out reminders")
132
  out2 = gr.Textbox(label="response or feed back?")
133
 
134
+ btn1.click(fn=app2_response, inputs=[image_box], outputs=out1)
135
  btn2.click(fn=send_SMS, inputs=out1, outputs=out2)
136
 
137
  gr.Markdown("""