JeCabrera commited on
Commit
ec618b2
verified
1 Parent(s): de356ae

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +11 -11
app.py CHANGED
@@ -92,7 +92,7 @@ story_formulas = {
92
  }
93
  }
94
 
95
- def generate_story(formula_type, **kwargs):
96
  """Funci贸n unificada para generar historias"""
97
  model = genai.GenerativeModel("gemini-1.5-flash")
98
 
@@ -103,17 +103,17 @@ def generate_story(formula_type, **kwargs):
103
 
104
  prompt = f"""{system_prompt}
105
 
106
- Como experto copywriter, crea una historia persuasiva en espa帽ol de {kwargs['length']} palabras con un tono {kwargs['mood']}, siguiendo la estructura:
107
 
108
  {formula_description}
109
 
110
- P煤blico objetivo: {kwargs['target_audience']}
111
- Producto/Servicio: {kwargs['product']}
112
- Llamada a acci贸n: {kwargs['action']}
113
  """
114
 
115
- if formula_type == "GHA" and 'story_topic' in kwargs:
116
- prompt += f"\nTema de la historia: {kwargs['story_topic']}"
117
 
118
  response = model.generate_content([prompt])
119
  if response and response.parts:
@@ -162,16 +162,16 @@ with col2:
162
  if target_audience and product and action:
163
  try:
164
  if formula == "P.A.S.A.":
165
- response = get_pasa_response(target_audience, product, action, mood, length)
166
  elif formula == "A.D.P.":
167
- response = get_adp_response(target_audience, product, action, mood, length)
168
  elif formula == "G.H.A.":
169
  if story_topic:
170
- response = get_gha_response(target_audience, product, action, mood, length, story_topic)
171
  else:
172
  st.error("Por favor, completa todos los campos requeridos para la f贸rmula G.H.A.")
173
  response = ""
174
-
175
  if response:
176
  st.subheader("Historia generada:")
177
  st.write(response)
 
92
  }
93
  }
94
 
95
+ def generate_story(formula_type, target_audience, product, action, mood, length, story_topic=None):
96
  """Funci贸n unificada para generar historias"""
97
  model = genai.GenerativeModel("gemini-1.5-flash")
98
 
 
103
 
104
  prompt = f"""{system_prompt}
105
 
106
+ Como experto copywriter, crea una historia persuasiva en espa帽ol de {length} palabras con un tono {mood}, siguiendo la estructura:
107
 
108
  {formula_description}
109
 
110
+ P煤blico objetivo: {target_audience}
111
+ Producto/Servicio: {product}
112
+ Llamada a acci贸n: {action}
113
  """
114
 
115
+ if formula_type == "GHA" and story_topic:
116
+ prompt += f"\nTema de la historia: {story_topic}"
117
 
118
  response = model.generate_content([prompt])
119
  if response and response.parts:
 
162
  if target_audience and product and action:
163
  try:
164
  if formula == "P.A.S.A.":
165
+ response = generate_story("PASA", target_audience, product, action, mood, length)
166
  elif formula == "A.D.P.":
167
+ response = generate_story("ADP", target_audience, product, action, mood, length)
168
  elif formula == "G.H.A.":
169
  if story_topic:
170
+ response = generate_story("GHA", target_audience, product, action, mood, length, story_topic)
171
  else:
172
  st.error("Por favor, completa todos los campos requeridos para la f贸rmula G.H.A.")
173
  response = ""
174
+
175
  if response:
176
  st.subheader("Historia generada:")
177
  st.write(response)