Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -240,8 +240,6 @@ def chat_function(message, history):
|
|
240 |
"rId97": "images/rId97.png",
|
241 |
}
|
242 |
|
243 |
-
|
244 |
-
|
245 |
for tag in tags_detected:
|
246 |
for key, path in tags_to_images.items():
|
247 |
if key in tag and check_image_exists(path):
|
@@ -250,6 +248,18 @@ def chat_function(message, history):
|
|
250 |
|
251 |
return full_response, image_url
|
252 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
253 |
|
254 |
def update_image(image_url):
|
255 |
if image_url:
|
@@ -328,16 +338,11 @@ with gr.Blocks() as demo:
|
|
328 |
with gr.Column():
|
329 |
with gr.Accordion(category_name, open=False):
|
330 |
for question in questions:
|
331 |
-
gr.Button(question)
|
332 |
-
|
333 |
-
|
334 |
-
|
335 |
-
|
336 |
-
for question in questions:
|
337 |
-
button_assignments.append((question, question))
|
338 |
-
|
339 |
-
for question, prompt in button_assignments:
|
340 |
-
gr.Button(question).click(send_preset_question, inputs=[gr.State(value=prompt), chatbot_history], outputs=[chatbot_output, chatbot_history, image_url])
|
341 |
|
342 |
submit_button.click(process_input, inputs=[chatbot_input, chatbot_history], outputs=[chatbot_output, chatbot_history, image_url])
|
343 |
image_url.change(fn=update_image, inputs=image_url, outputs=image_output)
|
@@ -346,3 +351,4 @@ with gr.Blocks() as demo:
|
|
346 |
demo.launch(debug=True)
|
347 |
|
348 |
|
|
|
|
240 |
"rId97": "images/rId97.png",
|
241 |
}
|
242 |
|
|
|
|
|
243 |
for tag in tags_detected:
|
244 |
for key, path in tags_to_images.items():
|
245 |
if key in tag and check_image_exists(path):
|
|
|
248 |
|
249 |
return full_response, image_url
|
250 |
|
251 |
+
# Funci贸n para procesar preguntas preestablecidas
|
252 |
+
def send_preset_question(question, history):
|
253 |
+
# Aqu铆 puedes definir c贸mo manejar la pregunta, por ejemplo:
|
254 |
+
response = f"Procesando la pregunta: {question}"
|
255 |
+
history.append((question, response))
|
256 |
+
return history, history, None
|
257 |
+
|
258 |
+
# Funci贸n para manejar la entrada manual
|
259 |
+
def process_input(message, history):
|
260 |
+
response = f"Respuesta generada para: {message}"
|
261 |
+
history.append((message, response))
|
262 |
+
return history, history, None
|
263 |
|
264 |
def update_image(image_url):
|
265 |
if image_url:
|
|
|
338 |
with gr.Column():
|
339 |
with gr.Accordion(category_name, open=False):
|
340 |
for question in questions:
|
341 |
+
gr.Button(question).click(
|
342 |
+
send_preset_question,
|
343 |
+
inputs=[gr.State(value=question), chatbot_history],
|
344 |
+
outputs=[chatbot_output, chatbot_history, image_url]
|
345 |
+
)
|
|
|
|
|
|
|
|
|
|
|
346 |
|
347 |
submit_button.click(process_input, inputs=[chatbot_input, chatbot_history], outputs=[chatbot_output, chatbot_history, image_url])
|
348 |
image_url.change(fn=update_image, inputs=image_url, outputs=image_output)
|
|
|
351 |
demo.launch(debug=True)
|
352 |
|
353 |
|
354 |
+
|