JeCabrera commited on
Commit
88f44b0
verified
1 Parent(s): 4e533dc

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +20 -9
app.py CHANGED
@@ -128,21 +128,32 @@ with col1:
128
 
129
  # Generate button with callback
130
  def generate_offer():
131
- has_manual_input = bool(skills and product_service)
132
  has_file_input = bool('uploaded_file' in locals() and uploaded_file is not None)
133
  has_image_input = bool('uploaded_image' in locals() and uploaded_image is not None)
134
 
135
- # Handle all scenarios
136
- if not (has_manual_input or has_file_input or has_image_input):
137
- st.error('Por favor ingresa texto, sube un archivo o una imagen')
 
 
 
 
 
 
 
 
 
 
 
138
  return
139
 
140
  st.session_state.submitted = True
141
 
142
  # Store inputs based on what's available
143
  if has_manual_input:
144
- st.session_state.skills = skills
145
- st.session_state.product_service = product_service
146
 
147
  if has_file_input:
148
  st.session_state.file_content = file_content
@@ -152,9 +163,7 @@ with col1:
152
 
153
  # Set input type
154
  if has_image_input:
155
- if has_manual_input and has_file_input:
156
- st.session_state.input_type = "all"
157
- elif has_manual_input:
158
  st.session_state.input_type = "manual_image"
159
  elif has_file_input:
160
  st.session_state.input_type = "file_image"
@@ -163,6 +172,8 @@ with col1:
163
  else:
164
  if has_manual_input and has_file_input:
165
  st.session_state.input_type = "both"
 
 
166
  elif has_manual_input:
167
  st.session_state.input_type = "manual"
168
  else:
 
128
 
129
  # Generate button with callback
130
  def generate_offer():
131
+ has_manual_input = bool(skills or product_service) # Changed from 'and' to 'or'
132
  has_file_input = bool('uploaded_file' in locals() and uploaded_file is not None)
133
  has_image_input = bool('uploaded_image' in locals() and uploaded_image is not None)
134
 
135
+ # Check for valid combinations
136
+ valid_input = (
137
+ (has_manual_input and (has_file_input or has_image_input)) or # Text + (file or image)
138
+ (not has_manual_input and (has_file_input or has_image_input)) or # Only file or image
139
+ has_file_input or # Only file
140
+ has_image_input # Only image
141
+ )
142
+
143
+ if not valid_input:
144
+ st.error('Por favor ingresa una combinaci贸n v谩lida:\n' +
145
+ '- Texto + (archivo o imagen)\n' +
146
+ '- Solo archivo o imagen\n' +
147
+ '- Solo archivo\n' +
148
+ '- Solo imagen')
149
  return
150
 
151
  st.session_state.submitted = True
152
 
153
  # Store inputs based on what's available
154
  if has_manual_input:
155
+ st.session_state.skills = skills if skills else ""
156
+ st.session_state.product_service = product_service if product_service else ""
157
 
158
  if has_file_input:
159
  st.session_state.file_content = file_content
 
163
 
164
  # Set input type
165
  if has_image_input:
166
+ if has_manual_input:
 
 
167
  st.session_state.input_type = "manual_image"
168
  elif has_file_input:
169
  st.session_state.input_type = "file_image"
 
172
  else:
173
  if has_manual_input and has_file_input:
174
  st.session_state.input_type = "both"
175
+ elif has_file_input:
176
+ st.session_state.input_type = "file"
177
  elif has_manual_input:
178
  st.session_state.input_type = "manual"
179
  else: