Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -2,7 +2,6 @@ from dotenv import load_dotenv
|
|
| 2 |
import streamlit as st
|
| 3 |
import os
|
| 4 |
import google.generativeai as genai
|
| 5 |
-
from langdetect import detect
|
| 6 |
|
| 7 |
# Cargar variables de entorno
|
| 8 |
load_dotenv()
|
|
@@ -11,21 +10,10 @@ load_dotenv()
|
|
| 11 |
genai.configure(api_key=os.getenv("GOOGLE_API_KEY"))
|
| 12 |
|
| 13 |
# Funci贸n para obtener la respuesta del modelo Gemini
|
| 14 |
-
|
| 15 |
-
def get_gemini_response(input_prompt, genre, length, mood, target_audience, cta_type):
|
| 16 |
-
if not input_prompt:
|
| 17 |
-
return "Por favor, escribe un mensaje para generar contenido."
|
| 18 |
-
|
| 19 |
-
# Better language detection
|
| 20 |
-
try:
|
| 21 |
-
detected_lang = detect(input_prompt)
|
| 22 |
-
language = "Espa帽ol" if detected_lang == "es" else "English"
|
| 23 |
-
except:
|
| 24 |
-
language = "Espa帽ol" # Default to Spanish if detection fails
|
| 25 |
-
|
| 26 |
model = genai.GenerativeModel('gemini-2.0-flash')
|
| 27 |
full_prompt = f"""
|
| 28 |
-
You are a creative storyteller. Write a {mood} {genre} about "{input_prompt}" using everyday words and natural conversation.
|
| 29 |
Write in the same language as the input prompt ({language}).
|
| 30 |
Use exactly {length} words.
|
| 31 |
|
|
|
|
| 2 |
import streamlit as st
|
| 3 |
import os
|
| 4 |
import google.generativeai as genai
|
|
|
|
| 5 |
|
| 6 |
# Cargar variables de entorno
|
| 7 |
load_dotenv()
|
|
|
|
| 10 |
genai.configure(api_key=os.getenv("GOOGLE_API_KEY"))
|
| 11 |
|
| 12 |
# Funci贸n para obtener la respuesta del modelo Gemini
|
| 13 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 14 |
model = genai.GenerativeModel('gemini-2.0-flash')
|
| 15 |
full_prompt = f"""
|
| 16 |
+
You are a creative storyteller. Write a {mood} {genre} in Spanish about "{input_prompt}" using everyday words and natural conversation.
|
| 17 |
Write in the same language as the input prompt ({language}).
|
| 18 |
Use exactly {length} words.
|
| 19 |
|