Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
|
@@ -219,21 +219,31 @@ def simple_chat(message: dict, temperature: float = 0.8, max_length: int = 4096,
|
|
| 219 |
|
| 220 |
conversation = []
|
| 221 |
|
| 222 |
-
#
|
| 223 |
-
|
| 224 |
-
|
| 225 |
-
|
| 226 |
-
|
| 227 |
-
|
| 228 |
-
|
| 229 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 230 |
if choice == "image":
|
| 231 |
-
conversation.append({"role": "user", "image": contents, "content": message
|
| 232 |
elif choice == "doc":
|
| 233 |
-
format_msg = contents + "\n\n\n" + "{} files uploaded.\n" + message
|
| 234 |
conversation.append({"role": "user", "content": format_msg})
|
| 235 |
else:
|
| 236 |
-
conversation.append({"role": "user", "content": message
|
| 237 |
|
| 238 |
# Preparar entrada para el modelo
|
| 239 |
input_ids = tokenizer.apply_chat_template(conversation, tokenize=True, add_generation_prompt=True,
|
|
|
|
| 219 |
|
| 220 |
conversation = []
|
| 221 |
|
| 222 |
+
# if message.file:
|
| 223 |
+
# file_contents = message.file.file.read()
|
| 224 |
+
# # Aquí deberías procesar el archivo como corresponda, por ejemplo:
|
| 225 |
+
# # choice, contents = mode_load(file_contents)
|
| 226 |
+
# # Por ahora solo agregaremos un marcador de posición
|
| 227 |
+
# choice = "doc"
|
| 228 |
+
# contents = "Contenido del archivo"
|
| 229 |
+
# if choice == "image":
|
| 230 |
+
# conversation.append({"role": "user", "image": contents, "content": message.text})
|
| 231 |
+
# elif choice == "doc":
|
| 232 |
+
# format_msg = contents + "\n\n\n" + "{} files uploaded.\n" + message.text
|
| 233 |
+
# conversation.append({"role": "user", "content": format_msg})
|
| 234 |
+
# else:
|
| 235 |
+
# conversation.append({"role": "user", "content": message.text})
|
| 236 |
+
|
| 237 |
+
if "file" in message and message["file"]:
|
| 238 |
+
file_path = message["file"]
|
| 239 |
+
choice, contents = mode_load(file_path)
|
| 240 |
if choice == "image":
|
| 241 |
+
conversation.append({"role": "user", "image": contents, "content": message["text"]})
|
| 242 |
elif choice == "doc":
|
| 243 |
+
format_msg = contents + "\n\n\n" + "{} files uploaded.\n" + message["text"]
|
| 244 |
conversation.append({"role": "user", "content": format_msg})
|
| 245 |
else:
|
| 246 |
+
conversation.append({"role": "user", "content": message["text"]})
|
| 247 |
|
| 248 |
# Preparar entrada para el modelo
|
| 249 |
input_ids = tokenizer.apply_chat_template(conversation, tokenize=True, add_generation_prompt=True,
|