prateekbh commited on
Commit
59348e4
1 Parent(s): 436c517

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +15 -6
app.py CHANGED
@@ -47,13 +47,16 @@ def format_prompt(message, history):
47
  prompt += f"<start_of_turn>user{message}<end_of_turn><start_of_turn>modelo"
48
  return prompt
49
 
50
- def getProductDetails(history, image):
51
  product_description=getImageDescription(image)
52
  system_prompt="You're a helpful e-commerce marketing assitant working on art products."
53
  prompt="Our product description is as follows: " + product_description + ". Please write a product title options for it."
54
  yield interactWithModel(history, system_prompt, prompt)
55
- prompt2="Please also write an SEO friendly description for it describing its value to its users."
56
- yield interactWithModel(history, system_prompt, prompt2)
 
 
 
57
 
58
 
59
  def interactWithModel(history, system_prompt, prompt):
@@ -187,12 +190,18 @@ with gr.Blocks(css=css) as demo:
187
  with gr.Column():
188
  output = gr.Image(type="pil", interactive=False)
189
 
190
- response_handler = (
191
- getProductDetails,
192
  [chat, image],
193
  [chat]
194
  )
195
 
 
 
 
 
 
 
196
  background_remover_handler = (
197
  process,
198
  [image],
@@ -205,7 +214,7 @@ with gr.Blocks(css=css) as demo:
205
  # [submit]
206
  # )
207
 
208
- event = submit.click(*response_handler)
209
  event2 = submit.click(*background_remover_handler)
210
  # event.then(*postresponse_handler)
211
 
 
47
  prompt += f"<start_of_turn>user{message}<end_of_turn><start_of_turn>modelo"
48
  return prompt
49
 
50
+ def getProductTitle(history, image):
51
  product_description=getImageDescription(image)
52
  system_prompt="You're a helpful e-commerce marketing assitant working on art products."
53
  prompt="Our product description is as follows: " + product_description + ". Please write a product title options for it."
54
  yield interactWithModel(history, system_prompt, prompt)
55
+
56
+ def getProductDescription(history):
57
+ system_prompt="You're a helpful e-commerce marketing assitant working on art products."
58
+ prompt="Please also write an SEO friendly description for it describing its value to its users."
59
+ yield interactWithModel(history, system_prompt, prompt)
60
 
61
 
62
  def interactWithModel(history, system_prompt, prompt):
 
190
  with gr.Column():
191
  output = gr.Image(type="pil", interactive=False)
192
 
193
+ title_handler = (
194
+ getProductTitle,
195
  [chat, image],
196
  [chat]
197
  )
198
 
199
+ description_handler = (
200
+ getProductDescription,
201
+ [chat],
202
+ [chat]
203
+ )
204
+
205
  background_remover_handler = (
206
  process,
207
  [image],
 
214
  # [submit]
215
  # )
216
 
217
+ event = submit.click(*title_handler).then(*description_handler)
218
  event2 = submit.click(*background_remover_handler)
219
  # event.then(*postresponse_handler)
220