JeCabrera commited on
Commit
515ce75
·
verified ·
1 Parent(s): 29ac940

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +44 -45
app.py CHANGED
@@ -49,6 +49,50 @@ col1, col2 = st.columns([4, 6])
49
 
50
  # Main input section in left column
51
  with col1:
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
52
  # Keep only the manual input tab
53
  with st.container():
54
  skills = st.text_area('💪 Tus Habilidades', height=70,
@@ -135,51 +179,6 @@ with col1:
135
  temperature = st.slider('🌡️ Nivel de Creatividad', min_value=0.0, max_value=2.0, value=0.7,
136
  help='Valores más altos hacen que el resultado sea más creativo pero menos enfocado')
137
 
138
- def generate_offer():
139
- has_manual_input = bool(skills or product_service)
140
- has_file_input = bool(uploaded_file is not None and not is_image)
141
- has_image_input = bool(uploaded_file is not None and is_image)
142
-
143
- # Simple validation - check if we have at least one input type
144
- if not (has_manual_input or has_file_input or has_image_input):
145
- st.error('Por favor ingresa texto o sube un archivo/imagen')
146
- return
147
-
148
- st.session_state.submitted = True
149
- st.session_state.generated = False # Reset generated flag
150
-
151
- # Store inputs based on what's available
152
- if has_manual_input:
153
- st.session_state.skills = skills if skills else ""
154
- st.session_state.product_service = product_service if product_service else ""
155
-
156
- if has_file_input:
157
- st.session_state.file_content = file_content
158
-
159
- if has_image_input:
160
- st.session_state.image_parts = image_parts
161
-
162
- # Set input type based on what's available
163
- if has_image_input:
164
- if has_manual_input:
165
- st.session_state.input_type = "manual_image"
166
- else:
167
- st.session_state.input_type = "image"
168
- else:
169
- if has_manual_input and has_file_input:
170
- st.session_state.input_type = "both"
171
- elif has_file_input:
172
- st.session_state.input_type = "file"
173
- elif has_manual_input:
174
- st.session_state.input_type = "manual"
175
-
176
- # Store common settings
177
- st.session_state.target_audience = target_audience
178
- st.session_state.temperature = temperature
179
- st.session_state.formula_type = formula_type
180
-
181
- st.button('Generar Oferta 🎉', on_click=generate_offer)
182
-
183
  # Results column
184
  with col2:
185
  if st.session_state.submitted and not st.session_state.generated:
 
49
 
50
  # Main input section in left column
51
  with col1:
52
+ # Define the generate_offer function first
53
+ def generate_offer():
54
+ has_manual_input = bool(skills or product_service)
55
+ has_file_input = bool(uploaded_file is not None and not is_image)
56
+ has_image_input = bool(uploaded_file is not None and is_image)
57
+
58
+ # Simple validation - check if we have at least one input type
59
+ if not (has_manual_input or has_file_input or has_image_input):
60
+ st.error('Por favor ingresa texto o sube un archivo/imagen')
61
+ return
62
+
63
+ st.session_state.submitted = True
64
+ st.session_state.generated = False # Reset generated flag
65
+
66
+ # Store inputs based on what's available
67
+ if has_manual_input:
68
+ st.session_state.skills = skills if skills else ""
69
+ st.session_state.product_service = product_service if product_service else ""
70
+
71
+ if has_file_input:
72
+ st.session_state.file_content = file_content
73
+
74
+ if has_image_input:
75
+ st.session_state.image_parts = image_parts
76
+
77
+ # Set input type based on what's available
78
+ if has_image_input:
79
+ if has_manual_input:
80
+ st.session_state.input_type = "manual_image"
81
+ else:
82
+ st.session_state.input_type = "image"
83
+ else:
84
+ if has_manual_input and has_file_input:
85
+ st.session_state.input_type = "both"
86
+ elif has_file_input:
87
+ st.session_state.input_type = "file"
88
+ elif has_manual_input:
89
+ st.session_state.input_type = "manual"
90
+
91
+ # Store common settings
92
+ st.session_state.target_audience = target_audience
93
+ st.session_state.temperature = temperature
94
+ st.session_state.formula_type = formula_type
95
+
96
  # Keep only the manual input tab
97
  with st.container():
98
  skills = st.text_area('💪 Tus Habilidades', height=70,
 
179
  temperature = st.slider('🌡️ Nivel de Creatividad', min_value=0.0, max_value=2.0, value=0.7,
180
  help='Valores más altos hacen que el resultado sea más creativo pero menos enfocado')
181
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
182
  # Results column
183
  with col2:
184
  if st.session_state.submitted and not st.session_state.generated: