Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -292,3 +292,72 @@ else:
|
|
292 |
section_key = normalize_section_key(sales_page_section)
|
293 |
if section_key in st.session_state.sections['content']:
|
294 |
display_generated_content(col2, st.session_state.sections['content'][section_key], "sales_page_section", sales_page_section)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
292 |
section_key = normalize_section_key(sales_page_section)
|
293 |
if section_key in st.session_state.sections['content']:
|
294 |
display_generated_content(col2, st.session_state.sections['content'][section_key], "sales_page_section", sales_page_section)
|
295 |
+
|
296 |
+
|
297 |
+
def update_section_context(section_name, content):
|
298 |
+
"""Update the context for a section after it's generated."""
|
299 |
+
section_key = normalize_section_key(section_name)
|
300 |
+
|
301 |
+
# Store in content dictionary
|
302 |
+
if 'content' not in st.session_state.sections:
|
303 |
+
st.session_state.sections['content'] = {}
|
304 |
+
st.session_state.sections['content'][section_key] = content
|
305 |
+
|
306 |
+
# Store in context dictionary with timestamp
|
307 |
+
if 'context' not in st.session_state.sections:
|
308 |
+
st.session_state.sections['context'] = {}
|
309 |
+
|
310 |
+
st.session_state.sections['context'][section_key] = {
|
311 |
+
'content': content,
|
312 |
+
'timestamp': datetime.datetime.now().isoformat()
|
313 |
+
}
|
314 |
+
|
315 |
+
def get_relevant_context(current_section):
|
316 |
+
"""Get relevant context based on current section"""
|
317 |
+
context = {}
|
318 |
+
|
319 |
+
section_key = normalize_section_key(current_section)
|
320 |
+
|
321 |
+
if section_key == 'above_the_fold':
|
322 |
+
return context
|
323 |
+
|
324 |
+
specific_relationships = {
|
325 |
+
'problem': ['above_the_fold'],
|
326 |
+
'solution_&_benefits': ['problem'],
|
327 |
+
'authority': ['problem', 'solution_&_benefits'],
|
328 |
+
'offer_&_bonus': ['solution_&_benefits', 'problem'],
|
329 |
+
'social_proof': ['offer_&_bonus', 'solution_&_benefits'],
|
330 |
+
'offer_summary': ['offer_&_bonus', 'solution_&_benefits'],
|
331 |
+
'guarantees': ['offer_&_bonus', 'social_proof'],
|
332 |
+
'faq': ['offer_&_bonus', 'guarantees', 'problem'],
|
333 |
+
'closing': ['offer_&_bonus', 'guarantees', 'problem', 'solution_&_benefits']
|
334 |
+
}
|
335 |
+
|
336 |
+
section_order = [
|
337 |
+
"above_the_fold",
|
338 |
+
"problem",
|
339 |
+
"solution_&_benefits",
|
340 |
+
"authority",
|
341 |
+
"offer_&_bonus",
|
342 |
+
"social_proof",
|
343 |
+
"offer_summary",
|
344 |
+
"guarantees",
|
345 |
+
"faq",
|
346 |
+
"closing"
|
347 |
+
]
|
348 |
+
|
349 |
+
# First, add specific relationships if they exist
|
350 |
+
if section_key in specific_relationships:
|
351 |
+
for rel_section in specific_relationships[section_key]:
|
352 |
+
if rel_section in st.session_state.sections['context']:
|
353 |
+
context[rel_section] = st.session_state.sections['context'][rel_section]['content']
|
354 |
+
|
355 |
+
# Then, for any section after "above_the_fold", add previous sections as context
|
356 |
+
if section_key in section_order:
|
357 |
+
current_index = section_order.index(section_key)
|
358 |
+
if current_index > 0:
|
359 |
+
for prev_section in section_order[:current_index][-3:]:
|
360 |
+
if prev_section in st.session_state.sections['context'] and prev_section not in context:
|
361 |
+
context[prev_section] = st.session_state.sections['context'][prev_section]['content']
|
362 |
+
|
363 |
+
return context
|