Update app.py
Browse files
app.py
CHANGED
@@ -190,29 +190,30 @@ Create {number_of_emails} emails that faithfully follow the style and structure
|
|
190 |
"""
|
191 |
|
192 |
# Modificar la forma de enviar el mensaje según si hay imagen o no
|
|
|
|
|
|
|
193 |
if is_image and image_parts:
|
194 |
-
|
195 |
-
|
196 |
-
{
|
197 |
-
"role": "user",
|
198 |
-
"parts": [
|
199 |
-
email_instruction,
|
200 |
-
image_parts
|
201 |
-
],
|
202 |
-
},
|
203 |
-
]
|
204 |
-
)
|
205 |
-
response = chat_session.send_message("Genera los emails en español siguiendo exactamente el estilo de los ejemplos mostrados, inspirándote en la imagen proporcionada. No incluyas explicaciones, solo los emails. IMPORTANTE: No incluyas saludos como 'Hola [Nombre]' y asegúrate que las postdatas (P.D.) sean más pequeñas y discretas que el cuerpo principal del email, usando un formato más ligero.")
|
206 |
else:
|
207 |
-
|
208 |
-
|
209 |
-
|
210 |
-
|
211 |
-
|
212 |
-
|
213 |
-
|
214 |
-
|
215 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
216 |
|
217 |
return response.text
|
218 |
|
|
|
190 |
"""
|
191 |
|
192 |
# Modificar la forma de enviar el mensaje según si hay imagen o no
|
193 |
+
message_parts = [email_instruction]
|
194 |
+
|
195 |
+
# Add the image to the message parts if it exists
|
196 |
if is_image and image_parts:
|
197 |
+
message_parts.append(image_parts)
|
198 |
+
instruction_text = "Generate the emails in Spanish following exactly the style of the examples shown, drawing inspiration from the provided image."
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
199 |
else:
|
200 |
+
instruction_text = "Generate the emails in Spanish following exactly the style of the examples shown."
|
201 |
+
|
202 |
+
# Common instruction for both cases
|
203 |
+
instruction_text += " Do not include explanations, only the emails. IMPORTANT: Do not include greetings like 'Hello [Name]' and make sure that the postscripts (P.D.) are smaller and more discrete than the main body of the email, using a lighter format."
|
204 |
+
|
205 |
+
# Create the chat session with the message parts
|
206 |
+
chat_session = model.start_chat(
|
207 |
+
history=[
|
208 |
+
{
|
209 |
+
"role": "user",
|
210 |
+
"parts": message_parts,
|
211 |
+
},
|
212 |
+
]
|
213 |
+
)
|
214 |
+
|
215 |
+
# Enviar el mensaje con las instrucciones
|
216 |
+
response = chat_session.send_message(instruction_text)
|
217 |
|
218 |
return response.text
|
219 |
|