Spaces:
Sleeping
Sleeping
import streamlit as st | |
import google.generativeai as genai | |
import os | |
from dotenv import load_dotenv | |
from styles import get_custom_css | |
# Load environment variables | |
load_dotenv() | |
# Configure Google Gemini API | |
genai.configure(api_key=os.getenv('GOOGLE_API_KEY')) | |
model = genai.GenerativeModel('gemini-pro') | |
# Hide Streamlit menu and footer | |
st.markdown(""" | |
<style> | |
#MainMenu {visibility: hidden;} | |
footer {visibility: hidden;} | |
header {visibility: hidden;} | |
</style> | |
""", unsafe_allow_html=True) | |
# Custom CSS | |
st.markdown(get_custom_css(), unsafe_allow_html=True) | |
# App title and description | |
st.title('🚀 Great Offer Generator') | |
st.markdown('''### Transform your skills into compelling offers!''') | |
# Create two columns for layout - left column 40%, right column 60% | |
col1, col2 = st.columns([4, 6]) | |
# Main input section in left column | |
with col1: | |
skills = st.text_area('💪 Your Skills', height=70, | |
help='List your key skills and expertise') | |
product_service = st.text_area('🎯 Product/Service', height=70, | |
help='Describe your product or service') | |
# Accordion for additional settings | |
with st.expander('⚙️ Advanced Settings'): | |
target_audience = st.text_area('👥 Target Audience', height=70, | |
help='Describe your ideal customer or client') | |
temperature = st.slider('🌡️ Creativity Level', min_value=0.0, max_value=2.0, value=0.7, | |
help='Higher values make the output more creative but less focused') | |
# Generate button | |
if st.button('Generate Offer 🎉'): | |
if not skills or not product_service: | |
st.error('Please fill in both Skills and Product/Service fields') | |
else: | |
with st.spinner('Creating your perfect offer...'): | |
prompt = f"""Based on the following information, create a compelling offer: | |
Skills: {skills} | |
Product/Service: {product_service} | |
Target Audience: {target_audience if target_audience else 'General audience'} | |
Please create a professional and engaging offer that highlights the value proposition | |
and appeals to the target audience. Include a clear call to action.""" | |
try: | |
# Create generation config with temperature | |
generation_config = genai.GenerationConfig(temperature=temperature) | |
# Pass the generation config to generate_content | |
response = model.generate_content(prompt, generation_config=generation_config) | |
st.success('✨ Your offer is ready!') | |
# Display result in the right column | |
with col2: | |
st.markdown('### 📝 Generated Offer') | |
st.markdown(response.text) | |
except Exception as e: | |
st.error(f'An error occurred: {str(e)}') | |
# Footer | |
st.markdown('---') | |
st.markdown('Made with ❤️ by Jesús Cabrera') |