Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -2,6 +2,7 @@ from dotenv import load_dotenv
|
|
2 |
import streamlit as st
|
3 |
import os
|
4 |
import google.generativeai as genai
|
|
|
5 |
|
6 |
# Cargar variables de entorno
|
7 |
load_dotenv()
|
@@ -15,9 +16,13 @@ def get_gemini_response(input_prompt, genre, length, mood, target_audience, cta_
|
|
15 |
if not input_prompt:
|
16 |
return "Por favor, escribe un mensaje para generar contenido."
|
17 |
|
18 |
-
|
19 |
-
|
20 |
-
|
|
|
|
|
|
|
|
|
21 |
model = genai.GenerativeModel('gemini-2.0-flash')
|
22 |
full_prompt = f"""
|
23 |
You are a creative storyteller. Write a {mood} {genre} about "{input_prompt}" using everyday words and natural conversation.
|
|
|
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()
|
|
|
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.
|