JeCabrera commited on
Commit
0ff427e
·
verified ·
1 Parent(s): 37ce3d4

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +34 -20
app.py CHANGED
@@ -109,26 +109,31 @@ with col1:
109
 
110
  # Generate button with callback
111
  def generate_offer():
112
- # Check which tab is active and what inputs are available
113
- if input_tab1._active:
114
- # Manual input tab is active
115
- if not skills and not product_service:
116
- st.error('Por favor completa los campos de Habilidades y Producto/Servicio')
117
- return
118
- else:
119
- st.session_state.submitted = True
120
- st.session_state.skills = skills
121
- st.session_state.product_service = product_service
122
- st.session_state.input_type = "manual"
 
 
 
 
 
 
 
 
 
 
 
 
123
  else:
124
- # File upload tab is active
125
- if uploaded_file is None:
126
- st.error('Por favor sube un archivo para generar la oferta')
127
- return
128
- else:
129
- st.session_state.submitted = True
130
- st.session_state.file_content = file_content
131
- st.session_state.input_type = "file"
132
 
133
  # Store common settings
134
  st.session_state.target_audience = target_audience
@@ -149,11 +154,20 @@ with col2:
149
  Product/Service: {st.session_state.product_service}
150
  Target Audience: {st.session_state.target_audience if st.session_state.target_audience else 'General audience'}
151
  """
152
- else: # file input
153
  prompt = f"""Based on the following information from the uploaded file, create a compelling offer using the {st.session_state.formula_type} formula:
154
  File Content: {st.session_state.file_content}
155
  Target Audience: {st.session_state.target_audience if st.session_state.target_audience else 'General audience'}
156
  """
 
 
 
 
 
 
 
 
 
157
 
158
  prompt += f"""
159
  Formula Description:
 
109
 
110
  # Generate button with callback
111
  def generate_offer():
112
+ has_manual_input = bool(skills and product_service)
113
+ has_file_input = bool(uploaded_file is not None)
114
+
115
+ # Handle all three scenarios
116
+ if not has_manual_input and not has_file_input:
117
+ st.error('Por favor ingresa texto o sube un archivo')
118
+ return
119
+
120
+ st.session_state.submitted = True
121
+
122
+ # Store inputs based on what's available
123
+ if has_manual_input:
124
+ st.session_state.skills = skills
125
+ st.session_state.product_service = product_service
126
+
127
+ if has_file_input:
128
+ st.session_state.file_content = file_content
129
+
130
+ # Set input type
131
+ if has_manual_input and has_file_input:
132
+ st.session_state.input_type = "both"
133
+ elif has_manual_input:
134
+ st.session_state.input_type = "manual"
135
  else:
136
+ st.session_state.input_type = "file"
 
 
 
 
 
 
 
137
 
138
  # Store common settings
139
  st.session_state.target_audience = target_audience
 
154
  Product/Service: {st.session_state.product_service}
155
  Target Audience: {st.session_state.target_audience if st.session_state.target_audience else 'General audience'}
156
  """
157
+ elif st.session_state.input_type == "file":
158
  prompt = f"""Based on the following information from the uploaded file, create a compelling offer using the {st.session_state.formula_type} formula:
159
  File Content: {st.session_state.file_content}
160
  Target Audience: {st.session_state.target_audience if st.session_state.target_audience else 'General audience'}
161
  """
162
+ else: # both inputs
163
+ prompt = f"""Based on the following combined information, create a compelling offer using the {st.session_state.formula_type} formula:
164
+ Skills: {st.session_state.skills}
165
+ Product/Service: {st.session_state.product_service}
166
+ Additional Information from File: {st.session_state.file_content}
167
+ Target Audience: {st.session_state.target_audience if st.session_state.target_audience else 'General audience'}
168
+
169
+ Please consider both the manual input and file content to create a comprehensive offer.
170
+ """
171
 
172
  prompt += f"""
173
  Formula Description: