Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -109,26 +109,31 @@ with col1:
|
|
109 |
|
110 |
# Generate button with callback
|
111 |
def generate_offer():
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
# Store input values in session state
|
121 |
-
if input_tab1._active:
|
122 |
st.session_state.skills = skills
|
123 |
st.session_state.product_service = product_service
|
124 |
st.session_state.input_type = "manual"
|
|
|
|
|
|
|
|
|
|
|
125 |
else:
|
|
|
126 |
st.session_state.file_content = file_content
|
127 |
st.session_state.input_type = "file"
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
|
|
132 |
|
133 |
st.button('Generar Oferta 🎉', on_click=generate_offer)
|
134 |
|
@@ -137,13 +142,14 @@ with col2:
|
|
137 |
# Check if form has been submitted
|
138 |
if st.session_state.submitted:
|
139 |
with st.spinner('Creando tu oferta perfecta...'):
|
|
|
140 |
if st.session_state.input_type == "manual":
|
141 |
prompt = f"""Based on the following information, create a compelling offer using the {st.session_state.formula_type} formula:
|
142 |
Skills: {st.session_state.skills}
|
143 |
Product/Service: {st.session_state.product_service}
|
144 |
Target Audience: {st.session_state.target_audience if st.session_state.target_audience else 'General audience'}
|
145 |
"""
|
146 |
-
else:
|
147 |
prompt = f"""Based on the following information from the uploaded file, create a compelling offer using the {st.session_state.formula_type} formula:
|
148 |
File Content: {st.session_state.file_content}
|
149 |
Target Audience: {st.session_state.target_audience if st.session_state.target_audience else 'General audience'}
|
|
|
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
|
135 |
+
st.session_state.temperature = temperature
|
136 |
+
st.session_state.formula_type = formula_type
|
137 |
|
138 |
st.button('Generar Oferta 🎉', on_click=generate_offer)
|
139 |
|
|
|
142 |
# Check if form has been submitted
|
143 |
if st.session_state.submitted:
|
144 |
with st.spinner('Creando tu oferta perfecta...'):
|
145 |
+
# Determine which input source to use
|
146 |
if st.session_state.input_type == "manual":
|
147 |
prompt = f"""Based on the following information, create a compelling offer using the {st.session_state.formula_type} formula:
|
148 |
Skills: {st.session_state.skills}
|
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'}
|