from dotenv import load_dotenv import streamlit as st import os import google.generativeai as genai from puv_formulas import puv_formulas from styles import apply_styles, format_creative_response from options import tone_options, creative_approaches import PyPDF2 import docx from PIL import Image import datetime # Add this import for timestamp # Cargar variables de entorno load_dotenv() # Configurar API de Google Gemini genai.configure(api_key=os.getenv("GOOGLE_API_KEY")) # Función para obtener la respuesta del modelo Gemini def get_gemini_response(product_service, target_audience, main_benefit, tone_of_voice, temperature, file_content="", image_parts=None, creative_approach=""): # Adjust prompt based on what's provided business_info = f"Target Audience: {target_audience}\n" business_info += f"Product/Service: {product_service}\n" business_info += f"Main Benefit: {main_benefit}\n" if tone_of_voice: business_info += f"Brand Tone of Voice: {tone_of_voice}\n" # Add creative approach to business info if provided if creative_approach: # Get the description from the dictionary from options import creative_approaches approach_description = creative_approaches.get(creative_approach, "") business_info += f"\nCREATIVE APPROACH: {creative_approach}\n" business_info += f"Description: {approach_description}\n" business_info += f"IMPORTANT: Please follow this creative approach strictly when generating concepts.\n" # Add file content if available reference_info = "" if file_content: reference_info = f"\nREFERENCE MATERIAL:\n{file_content}\n" model = genai.GenerativeModel('gemini-2.0-flash') full_prompt = f""" You are a Creative Concept expert. Analyze (internally only, do not output the analysis) the following information: BUSINESS INFORMATION: {business_info} {reference_info} A Creative Idea is a set of pieces created to sell a brand, product, or service, united by the same idea that is transmitted through a creative concept. First, analyze (but don't output) these points: 1. TARGET AUDIENCE ANALYSIS: - What everyday concepts are they familiar with? - What TV shows, movies, or cultural references resonate with them? - What emotions and experiences are meaningful to them? - What mental images would be easy for them to recall? 2. PRODUCT/SERVICE ANALYSIS: - What is the main benefit or promise? - What makes it unique or different? - What transformation does it offer? - What process or journey does the customer go through? Based on your internal analysis, create THREE different Creative Concepts in Spanish language. Each concept should be a DIRECT ANALOGY or METAPHOR that connects your product/service to something completely different but familiar. Examples of good creative concepts: - "Escribir copy es como cocinar tu plato favorito porque necesitas los ingredientes correctos para que todos quieran probarlo" - "Tu negocio es como un equipo de fútbol: necesita buenos jugadores (productos) y una estrategia clara para ganar clientes" - "Tu curso es como Netflix: ofrece contenido que engancha y soluciones que la gente realmente quiere ver" For each concept, include: CONCEPT: A clear statement of the main benefit CREATIVITY: A direct analogy or metaphor connecting your product to something completely different but familiar CRITICAL INSTRUCTIONS: - Each concept MUST use a direct "X es como Y porque Z" structure - Use SIMPLE, EVERYDAY language that anyone can understand - Avoid technical jargon, complex words, or business terminology - Write as if you're explaining to a friend in a casual conversation - Use everyday objects, activities, movies, TV shows or cultural references everyone knows - Make the connection SURPRISING and UNEXPECTED - connect things that normally wouldn't be connected - Challenge conventional thinking by finding parallels between your product and something completely different - Create analogies that make people say "I never thought of it that way!" - Focus on the main benefit - Create clear mental images - Be easy to remember - Use the brand's tone of voice if provided - Format with proper spacing between sections Output EXACTLY in this format (no additional text) in Spanish language: CONCEPTO CREATIVO 1: Concepto: [Main message/benefit in simple, conversational language] Creatividad: [Direct analogy using everyday language: "X es como Y porque Z"] CONCEPTO CREATIVO 2: Concepto: [Main message/benefit] Creatividad: [Direct analogy: "X es como Y porque Z"] CONCEPTO CREATIVO 3: Concepto: [Main message/benefit] Creatividad: [Direct analogy: "X es como Y porque Z"] """ # Handle text-only or text+image requests if image_parts: response = model.generate_content([full_prompt, image_parts], generation_config={"temperature": temperature}) else: response = model.generate_content([full_prompt], generation_config={"temperature": temperature}) return response.parts[0].text if response and response.parts else "Error generating content." # Configurar la aplicación Streamlit st.set_page_config(page_title="Generador de Ideas Creativas", page_icon="💡", layout="wide") # Aplicar estilos st.markdown(apply_styles(), unsafe_allow_html=True) # Título de la app st.markdown("