Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -98,11 +98,28 @@ def process_input(message, history, selected_option, similarity_threshold, syste
|
|
| 98 |
return history, history, image
|
| 99 |
|
| 100 |
def update_image(image_url):
|
| 101 |
-
|
| 102 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 103 |
else:
|
|
|
|
| 104 |
return None
|
| 105 |
|
|
|
|
| 106 |
def send_preset_question(question, history, selected_option, similarity_threshold, system_prompt, max_length):
|
| 107 |
return process_input(question, history, selected_option, similarity_threshold, system_prompt, max_length)
|
| 108 |
|
|
|
|
| 98 |
return history, history, image
|
| 99 |
|
| 100 |
def update_image(image_url):
|
| 101 |
+
"""
|
| 102 |
+
Retorna los datos binarios de la imagen para ser mostrados en Gradio.
|
| 103 |
+
|
| 104 |
+
Args:
|
| 105 |
+
image_url (str): Ruta de la imagen.
|
| 106 |
+
|
| 107 |
+
Returns:
|
| 108 |
+
bytes o None: Datos binarios de la imagen si existe, de lo contrario None.
|
| 109 |
+
"""
|
| 110 |
+
if image_url and os.path.exists(image_url):
|
| 111 |
+
try:
|
| 112 |
+
with open(image_url, "rb") as img_file:
|
| 113 |
+
image_data = img_file.read()
|
| 114 |
+
return image_data
|
| 115 |
+
except Exception as e:
|
| 116 |
+
print(f"Error al leer la imagen: {e}")
|
| 117 |
+
return None
|
| 118 |
else:
|
| 119 |
+
print("No se encontr贸 una imagen v谩lida.")
|
| 120 |
return None
|
| 121 |
|
| 122 |
+
|
| 123 |
def send_preset_question(question, history, selected_option, similarity_threshold, system_prompt, max_length):
|
| 124 |
return process_input(question, history, selected_option, similarity_threshold, system_prompt, max_length)
|
| 125 |
|