Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -12,7 +12,7 @@ load_dotenv()
|
|
12 |
genai.configure(api_key=os.getenv("GOOGLE_API_KEY"))
|
13 |
|
14 |
# Funci贸n para obtener la respuesta del modelo Gemini
|
15 |
-
def get_gemini_response(input_prompt, formula_type, length, mood, target_audience, cta_type):
|
16 |
if not input_prompt:
|
17 |
return "Por favor, escribe un mensaje para generar contenido."
|
18 |
|
@@ -52,7 +52,7 @@ def get_gemini_response(input_prompt, formula_type, length, mood, target_audienc
|
|
52 |
|
53 |
Format: Three clean story texts with natural paragraphs, separated by "---", no labels, no explanations.
|
54 |
"""
|
55 |
-
response = model.generate_content([full_prompt])
|
56 |
return response.parts[0].text if response and response.parts else "Error al generar contenido."
|
57 |
|
58 |
# Configurar la aplicaci贸n Streamlit
|
@@ -83,14 +83,22 @@ with col1:
|
|
83 |
options=list(story_formulas.keys()),
|
84 |
format_func=lambda x: x
|
85 |
)
|
86 |
-
# Remove or comment out this line
|
87 |
-
# st.info(story_formulas[formula_type])
|
88 |
|
89 |
length = st.slider("Longitud del texto (palabras):",
|
90 |
min_value=100,
|
91 |
max_value=150,
|
92 |
value=125,
|
93 |
step=5)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
94 |
mood = st.selectbox("Estado de 谩nimo:", ["Emocional", "Triste", "Feliz", "Horror", "Comedia", "Rom谩ntico"])
|
95 |
generate_button = st.button("Generar historia")
|
96 |
# Al inicio de la app
|
@@ -101,7 +109,8 @@ with col2:
|
|
101 |
if generate_button:
|
102 |
response = get_gemini_response(
|
103 |
input_prompt, formula_type, length,
|
104 |
-
mood, target_audience, cta_type
|
|
|
105 |
)
|
106 |
stories = response.split("---")
|
107 |
for i, story in enumerate(stories, 1):
|
|
|
12 |
genai.configure(api_key=os.getenv("GOOGLE_API_KEY"))
|
13 |
|
14 |
# Funci贸n para obtener la respuesta del modelo Gemini
|
15 |
+
def get_gemini_response(input_prompt, formula_type, length, mood, target_audience, cta_type, temperature):
|
16 |
if not input_prompt:
|
17 |
return "Por favor, escribe un mensaje para generar contenido."
|
18 |
|
|
|
52 |
|
53 |
Format: Three clean story texts with natural paragraphs, separated by "---", no labels, no explanations.
|
54 |
"""
|
55 |
+
response = model.generate_content([full_prompt], generation_config={"temperature": temperature})
|
56 |
return response.parts[0].text if response and response.parts else "Error al generar contenido."
|
57 |
|
58 |
# Configurar la aplicaci贸n Streamlit
|
|
|
83 |
options=list(story_formulas.keys()),
|
84 |
format_func=lambda x: x
|
85 |
)
|
|
|
|
|
86 |
|
87 |
length = st.slider("Longitud del texto (palabras):",
|
88 |
min_value=100,
|
89 |
max_value=150,
|
90 |
value=125,
|
91 |
step=5)
|
92 |
+
|
93 |
+
temperature = st.slider(
|
94 |
+
"Nivel de creatividad:",
|
95 |
+
min_value=0.0,
|
96 |
+
max_value=2.0,
|
97 |
+
value=1.0,
|
98 |
+
step=0.1,
|
99 |
+
help="Valores m谩s altos generan historias m谩s creativas pero menos predecibles. Valores m谩s bajos producen historias m谩s consistentes."
|
100 |
+
)
|
101 |
+
|
102 |
mood = st.selectbox("Estado de 谩nimo:", ["Emocional", "Triste", "Feliz", "Horror", "Comedia", "Rom谩ntico"])
|
103 |
generate_button = st.button("Generar historia")
|
104 |
# Al inicio de la app
|
|
|
109 |
if generate_button:
|
110 |
response = get_gemini_response(
|
111 |
input_prompt, formula_type, length,
|
112 |
+
mood, target_audience, cta_type,
|
113 |
+
temperature
|
114 |
)
|
115 |
stories = response.split("---")
|
116 |
for i, story in enumerate(stories, 1):
|