from dotenv import load_dotenv import streamlit as st import os import google.generativeai as genai load_dotenv() genai.configure(api_key=os.getenv("GOOGLE_API_KEY")) # Función para obtener respuesta del modelo Gemini def get_gemini_response(target_audience, product, text_type, length, product_mention, mood, model_choice): model = genai.GenerativeModel(model_choice) # Crear el prompt completo basado en los campos del frontend mention_instruction = "" if product_mention == "Direct": mention_instruction = f"Make sure to mention the product '{product}' directly in the text." elif product_mention == "Subtle": mention_instruction = f"Ensure that subtle and realistic references to the product '{product}' are included without explicitly mentioning it." elif product_mention == "Metaphor": mention_instruction = f"Refer to the product '{product}' through a metaphor, without mentioning it explicitly." full_prompt = f""" Eres un escritor creativo experto en el arte de la persuasión. Escribe una {length} {text_type} en español. El tono del {text_type} debe ser {mood} y estar diseñado específicamente para resonar emocionalmente con un público {target_audience}. {mention_instruction} Usa técnicas persuasivas para guiar al lector hacia una comprensión intuitiva de los beneficios del producto, enfocándote en crear una fuerte conexión emocional con la audiencia. """ response = model.generate_content([full_prompt]) # Comprobar si la respuesta es válida y devolver el texto if response and response.parts: return response.parts[0].text else: raise ValueError("Lo sentimos, intenta con una combinación diferente de entradas.") # Inicializar la aplicación Streamlit st.set_page_config(page_title="Poetic Vision", page_icon=":pencil:", layout="wide") # Configurar el diseño en ancho # Componentes principales de la UI st.markdown("