Update app.py
Browse files
app.py
CHANGED
@@ -49,17 +49,16 @@ def format_prompt(message, history):
|
|
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,
|
|
|
63 |
client = InferenceClient("google/gemma-7b-it")
|
64 |
rand_val = random.randint(1, 1111111111111111)
|
65 |
if not history:
|
@@ -185,10 +184,12 @@ with gr.Blocks(css=css) as demo:
|
|
185 |
with gr.Row():
|
186 |
with gr.Column(elem_id="col-container"):
|
187 |
image = gr.Image(type="pil")
|
188 |
-
|
189 |
submit = gr.Button(value="Upload", variant="primary")
|
190 |
with gr.Column():
|
191 |
-
|
|
|
|
|
192 |
|
193 |
title_handler = (
|
194 |
getProductTitle,
|
@@ -202,6 +203,12 @@ with gr.Blocks(css=css) as demo:
|
|
202 |
[chat]
|
203 |
)
|
204 |
|
|
|
|
|
|
|
|
|
|
|
|
|
205 |
background_remover_handler = (
|
206 |
process,
|
207 |
[image],
|
@@ -214,8 +221,9 @@ with gr.Blocks(css=css) as demo:
|
|
214 |
# [submit]
|
215 |
# )
|
216 |
|
217 |
-
|
218 |
-
|
|
|
219 |
# event.then(*postresponse_handler)
|
220 |
|
221 |
demo.launch()
|
|
|
49 |
|
50 |
def getProductTitle(history, image):
|
51 |
product_description=getImageDescription(image)
|
|
|
52 |
prompt="Our product description is as follows: " + product_description + ". Please write a product title options for it."
|
53 |
yield interactWithModel(history, system_prompt, prompt)
|
54 |
|
55 |
def getProductDescription(history):
|
|
|
56 |
prompt="Please also write an SEO friendly description for it describing its value to its users."
|
57 |
yield interactWithModel(history, system_prompt, prompt)
|
58 |
|
59 |
|
60 |
+
def interactWithModel(history, prompt):
|
61 |
+
system_prompt="You're a helpful e-commerce marketing assitant working on art products."
|
62 |
client = InferenceClient("google/gemma-7b-it")
|
63 |
rand_val = random.randint(1, 1111111111111111)
|
64 |
if not history:
|
|
|
184 |
with gr.Row():
|
185 |
with gr.Column(elem_id="col-container"):
|
186 |
image = gr.Image(type="pil")
|
187 |
+
output = gr.Image(type="pil", interactive=False)
|
188 |
submit = gr.Button(value="Upload", variant="primary")
|
189 |
with gr.Column():
|
190 |
+
chat = gr.Chatbot(show_label=False)
|
191 |
+
user_input= gr.Textbox()
|
192 |
+
send = gr.Button(value="Send")
|
193 |
|
194 |
title_handler = (
|
195 |
getProductTitle,
|
|
|
203 |
[chat]
|
204 |
)
|
205 |
|
206 |
+
interaction_handler = (
|
207 |
+
getProductDescription,
|
208 |
+
[chat, user_input],
|
209 |
+
[chat]
|
210 |
+
)
|
211 |
+
|
212 |
background_remover_handler = (
|
213 |
process,
|
214 |
[image],
|
|
|
221 |
# [submit]
|
222 |
# )
|
223 |
|
224 |
+
submit.click(*title_handler).then(*description_handler)
|
225 |
+
submit.click(*background_remover_handler)
|
226 |
+
send.click(*interaction_handler)
|
227 |
# event.then(*postresponse_handler)
|
228 |
|
229 |
demo.launch()
|