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 |
-
|
| 121 |
-
|
| 122 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 123 |
else:
|
| 124 |
-
|
| 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 |
-
|
| 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:
|