Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -79,10 +79,22 @@ def count_images(message, history):
|
|
79 |
total_images += 1
|
80 |
return f"You just uploaded {num_images} images, total uploaded: {total_images + num_images}"
|
81 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
82 |
# Crear la interfaz de Gradio
|
83 |
demo = gr.ChatInterface(
|
84 |
-
response, # Funci贸n de chat para manejar texto y archivos
|
85 |
-
examples=[
|
|
|
|
|
86 |
cache_examples=True,
|
87 |
multimodal=True, # Activar la modalidad multimodal
|
88 |
textbox=gr.MultimodalTextbox( # Configuraci贸n del cuadro de texto multimodal
|
@@ -92,18 +104,8 @@ demo = gr.ChatInterface(
|
|
92 |
)
|
93 |
)
|
94 |
|
95 |
-
# Funci贸n que se invoca al cargar im谩genes
|
96 |
-
def upload_images_handler(message, history):
|
97 |
-
# Procesar las im谩genes cargadas
|
98 |
-
image_paths = handle_uploaded_images(message["files"])
|
99 |
-
|
100 |
-
# Actualizar el historial con las im谩genes procesadas
|
101 |
-
history.append((None, image_paths))
|
102 |
-
|
103 |
-
return history, count_images(message, history)
|
104 |
-
|
105 |
# Conectar la funci贸n de carga de im谩genes con el evento de Gradio
|
106 |
-
demo.
|
107 |
|
108 |
# Iniciar la interfaz
|
109 |
demo.launch()
|
|
|
79 |
total_images += 1
|
80 |
return f"You just uploaded {num_images} images, total uploaded: {total_images + num_images}"
|
81 |
|
82 |
+
# Funci贸n que se invoca al cargar im谩genes
|
83 |
+
def upload_images_handler(files, history):
|
84 |
+
# Procesar las im谩genes cargadas
|
85 |
+
image_paths = handle_uploaded_images(files)
|
86 |
+
|
87 |
+
# Actualizar el historial con las im谩genes procesadas
|
88 |
+
history.append((None, image_paths))
|
89 |
+
|
90 |
+
return history, count_images({"files": files}, history)
|
91 |
+
|
92 |
# Crear la interfaz de Gradio
|
93 |
demo = gr.ChatInterface(
|
94 |
+
fn=response, # Funci贸n de chat para manejar texto y archivos
|
95 |
+
examples=[ # Ejemplos iniciales de mensajes
|
96 |
+
{"text": "No files", "files": []}
|
97 |
+
],
|
98 |
cache_examples=True,
|
99 |
multimodal=True, # Activar la modalidad multimodal
|
100 |
textbox=gr.MultimodalTextbox( # Configuraci贸n del cuadro de texto multimodal
|
|
|
104 |
)
|
105 |
)
|
106 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
107 |
# Conectar la funci贸n de carga de im谩genes con el evento de Gradio
|
108 |
+
demo.add_event("file_upload", upload_images_handler)
|
109 |
|
110 |
# Iniciar la interfaz
|
111 |
demo.launch()
|