Spaces:
Runtime error
Runtime error
Update updated_components.py
Browse files- updated_components.py +85 -147
updated_components.py
CHANGED
|
@@ -263,20 +263,12 @@ def render_storyboard_stage():
|
|
| 263 |
# Display storyboard for review with edit options
|
| 264 |
edited_storyboard = []
|
| 265 |
|
| 266 |
-
# Add
|
| 267 |
-
col1, col2
|
| 268 |
with col1:
|
| 269 |
-
# Get
|
| 270 |
-
|
| 271 |
-
|
| 272 |
-
ai_manager = get_ai_manager()
|
| 273 |
-
available_models = ai_manager.get_available_models()
|
| 274 |
-
except (ImportError, Exception):
|
| 275 |
-
available_models = {
|
| 276 |
-
"claude-3-sonnet-20250219": "Claude 3 Sonnet",
|
| 277 |
-
"claude-3-haiku-20250319": "Claude 3 Haiku",
|
| 278 |
-
"claude-3-opus-20250229": "Claude 3 Opus"
|
| 279 |
-
}
|
| 280 |
|
| 281 |
selected_model = st.selectbox(
|
| 282 |
"AI Model",
|
|
@@ -288,46 +280,7 @@ def render_storyboard_stage():
|
|
| 288 |
|
| 289 |
with col2:
|
| 290 |
if st.button("π Regenerate All", help="Create a new storyboard with current title/purpose"):
|
| 291 |
-
|
| 292 |
-
with st.spinner("π SlideGator.AI is rethinking your presentation structure..."):
|
| 293 |
-
storyboard = generate_storyboard(
|
| 294 |
-
st.session_state.presentation_title,
|
| 295 |
-
st.session_state.presentation_purpose,
|
| 296 |
-
st.session_state.target_audience,
|
| 297 |
-
model=selected_model
|
| 298 |
-
)
|
| 299 |
-
if storyboard:
|
| 300 |
-
st.session_state.storyboard = storyboard
|
| 301 |
-
st.success("Storyboard regenerated!")
|
| 302 |
-
st.rerun()
|
| 303 |
-
|
| 304 |
-
with col3:
|
| 305 |
-
if st.button("π Analyze Flow", help="Analyze the narrative flow of your presentation"):
|
| 306 |
-
with st.spinner("π§ Analyzing presentation flow..."):
|
| 307 |
-
# Convert storyboard to text for analysis
|
| 308 |
-
storyboard_text = ""
|
| 309 |
-
for i, slide in enumerate(st.session_state.storyboard):
|
| 310 |
-
storyboard_text += f"Slide {i+1}: {slide.get('title', 'Untitled')}\n"
|
| 311 |
-
storyboard_text += f"Purpose: {slide.get('purpose', '')}\n"
|
| 312 |
-
key_points = slide.get('key_points', [])
|
| 313 |
-
if isinstance(key_points, list):
|
| 314 |
-
for point in key_points:
|
| 315 |
-
storyboard_text += f"- {point}\n"
|
| 316 |
-
else:
|
| 317 |
-
storyboard_text += f"- {key_points}\n"
|
| 318 |
-
storyboard_text += "\n"
|
| 319 |
-
|
| 320 |
-
# Analyze the flow using available AI
|
| 321 |
-
try:
|
| 322 |
-
from agents import enhance_slide_component
|
| 323 |
-
from utils import generate_storyboard
|
| 324 |
-
|
| 325 |
-
# Just display a simple analysis for now
|
| 326 |
-
analysis = "Flow Analysis: Your presentation has a logical structure with a clear beginning, middle, and end. Consider adding more transition slides between major sections to improve the narrative flow."
|
| 327 |
-
st.info("### Presentation Flow Analysis")
|
| 328 |
-
st.write(analysis)
|
| 329 |
-
except Exception as e:
|
| 330 |
-
st.error(f"Error analyzing presentation flow: {str(e)}")
|
| 331 |
|
| 332 |
# Add slide button with options
|
| 333 |
col1, col2 = st.columns([3, 1])
|
|
@@ -361,59 +314,6 @@ def render_storyboard_stage():
|
|
| 361 |
|
| 362 |
st.rerun()
|
| 363 |
|
| 364 |
-
# Add slide templates section
|
| 365 |
-
with st.expander("π Slide Templates"):
|
| 366 |
-
st.write("Add pre-designed slide templates to your presentation:")
|
| 367 |
-
|
| 368 |
-
template_cols = st.columns(3)
|
| 369 |
-
|
| 370 |
-
slide_templates = [
|
| 371 |
-
{"name": "Section Divider", "icon": "π·οΈ", "title": "Section Title",
|
| 372 |
-
"purpose": "Introduce a new section",
|
| 373 |
-
"key_points": ["A clean slide to mark a new section of your presentation"]},
|
| 374 |
-
|
| 375 |
-
{"name": "Comparison", "icon": "βοΈ", "title": "Comparison",
|
| 376 |
-
"purpose": "Compare two options or approaches",
|
| 377 |
-
"key_points": ["Option A benefits", "Option A challenges", "Option B benefits", "Option B challenges"],
|
| 378 |
-
"visual_elements": ["Two-column layout", "Comparison table or chart"]},
|
| 379 |
-
|
| 380 |
-
{"name": "Quote", "icon": "π¬", "title": "Key Quote",
|
| 381 |
-
"purpose": "Highlight an important quote",
|
| 382 |
-
"key_points": ["The quote goes here", "- Attribution"],
|
| 383 |
-
"visual_elements": ["Quotation marks graphic", "Simple background"]},
|
| 384 |
-
|
| 385 |
-
{"name": "Data Visualization", "icon": "π", "title": "Key Metrics",
|
| 386 |
-
"purpose": "Present important data",
|
| 387 |
-
"key_points": ["Metric 1 and its significance", "Metric 2 and its significance", "Trends and patterns"],
|
| 388 |
-
"visual_elements": ["Chart or graph", "Data visualization"]},
|
| 389 |
-
|
| 390 |
-
{"name": "Call to Action", "icon": "π―", "title": "Next Steps",
|
| 391 |
-
"purpose": "Define clear action items",
|
| 392 |
-
"key_points": ["Specific action item 1", "Specific action item 2", "Timeline and ownership"],
|
| 393 |
-
"visual_elements": ["Arrow or path graphic", "Timeline visualization"]},
|
| 394 |
-
|
| 395 |
-
{"name": "Team Slide", "icon": "π₯", "title": "Our Team",
|
| 396 |
-
"purpose": "Introduce key team members",
|
| 397 |
-
"key_points": ["Team member 1 with role", "Team member 2 with role", "Team member 3 with role"],
|
| 398 |
-
"visual_elements": ["Team photos or icons", "Organizational chart"]}
|
| 399 |
-
]
|
| 400 |
-
|
| 401 |
-
for i, template in enumerate(slide_templates):
|
| 402 |
-
with template_cols[i % 3]:
|
| 403 |
-
if st.button(f"{template['icon']} {template['name']}", key=f"template_{template['name']}"):
|
| 404 |
-
# Create a new slide based on the template
|
| 405 |
-
new_slide = {
|
| 406 |
-
'title': template['title'],
|
| 407 |
-
'purpose': template['purpose'],
|
| 408 |
-
'key_points': template['key_points'],
|
| 409 |
-
'visual_elements': template.get('visual_elements', [])
|
| 410 |
-
}
|
| 411 |
-
|
| 412 |
-
# Add to storyboard
|
| 413 |
-
st.session_state.storyboard.append(new_slide)
|
| 414 |
-
st.success(f"Added {template['name']} slide!")
|
| 415 |
-
st.rerun()
|
| 416 |
-
|
| 417 |
# Display storyboard slides
|
| 418 |
for i, slide in enumerate(st.session_state.storyboard):
|
| 419 |
# Set current slide in session state when expander is opened
|
|
@@ -467,50 +367,88 @@ def render_storyboard_stage():
|
|
| 467 |
|
| 468 |
visual_elements = st.text_area(f"Visual Elements (one per line) ###{i}", value=visual_elements_text)
|
| 469 |
|
| 470 |
-
# AI enhancement options
|
| 471 |
-
|
| 472 |
-
|
| 473 |
-
|
| 474 |
-
|
| 475 |
-
|
| 476 |
-
|
|
|
|
| 477 |
|
| 478 |
-
|
| 479 |
-
|
| 480 |
-
|
| 481 |
-
|
| 482 |
-
|
| 483 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 484 |
|
| 485 |
-
if st.button("
|
| 486 |
-
|
| 487 |
-
|
| 488 |
-
|
| 489 |
-
|
| 490 |
-
|
| 491 |
-
|
| 492 |
-
|
| 493 |
-
|
|
|
|
|
|
|
|
|
|
| 494 |
|
| 495 |
-
|
| 496 |
-
|
| 497 |
-
|
| 498 |
-
|
| 499 |
-
|
| 500 |
-
|
| 501 |
-
|
| 502 |
-
if enhancement_type in ["Title", "All"]:
|
| 503 |
-
updated_slide, result = enhance_slide_component(updated_slide, "title")
|
| 504 |
-
|
| 505 |
-
if enhancement_type in ["Visual Suggestions", "All"]:
|
| 506 |
-
updated_slide, result = enhance_slide_component(updated_slide, "visuals")
|
| 507 |
-
|
| 508 |
-
# Update the storyboard with enhanced slide
|
| 509 |
-
st.session_state.storyboard[i] = updated_slide
|
| 510 |
-
st.success("Slide enhanced with AI!")
|
| 511 |
-
st.rerun()
|
| 512 |
-
except Exception as e:
|
| 513 |
-
st.error(f"Error enhancing slide: {str(e)}")
|
| 514 |
|
| 515 |
# Update storyboard with edits
|
| 516 |
edited_slide = {
|
|
|
|
| 263 |
# Display storyboard for review with edit options
|
| 264 |
edited_storyboard = []
|
| 265 |
|
| 266 |
+
# Add a "regenerate" button and AI options
|
| 267 |
+
col1, col2 = st.columns([3, 1])
|
| 268 |
with col1:
|
| 269 |
+
# Get AI models for regeneration
|
| 270 |
+
ai_manager = get_ai_manager()
|
| 271 |
+
available_models = ai_manager.get_available_models()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 272 |
|
| 273 |
selected_model = st.selectbox(
|
| 274 |
"AI Model",
|
|
|
|
| 280 |
|
| 281 |
with col2:
|
| 282 |
if st.button("π Regenerate All", help="Create a new storyboard with current title/purpose"):
|
| 283 |
+
st.info("Storyboard regeneration feature coming soon")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 284 |
|
| 285 |
# Add slide button with options
|
| 286 |
col1, col2 = st.columns([3, 1])
|
|
|
|
| 314 |
|
| 315 |
st.rerun()
|
| 316 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 317 |
# Display storyboard slides
|
| 318 |
for i, slide in enumerate(st.session_state.storyboard):
|
| 319 |
# Set current slide in session state when expander is opened
|
|
|
|
| 367 |
|
| 368 |
visual_elements = st.text_area(f"Visual Elements (one per line) ###{i}", value=visual_elements_text)
|
| 369 |
|
| 370 |
+
# AI enhancement options - USING COLUMNS INSTEAD OF NESTED EXPANDER
|
| 371 |
+
st.write("##### π§ AI Enhancement")
|
| 372 |
+
ai_cols = st.columns(2)
|
| 373 |
+
|
| 374 |
+
with ai_cols[0]:
|
| 375 |
+
# Get AI manager
|
| 376 |
+
ai_manager = get_ai_manager()
|
| 377 |
+
available_models = ai_manager.get_available_models()
|
| 378 |
|
| 379 |
+
enhancement_model = st.selectbox(
|
| 380 |
+
"AI Model",
|
| 381 |
+
options=list(available_models.keys()),
|
| 382 |
+
format_func=lambda x: available_models.get(x, x),
|
| 383 |
+
index=0,
|
| 384 |
+
key=f"enhance_model_{i}"
|
| 385 |
+
)
|
| 386 |
+
|
| 387 |
+
with ai_cols[1]:
|
| 388 |
+
enhancement_type = st.selectbox(
|
| 389 |
+
"Enhancement Type",
|
| 390 |
+
["Content", "Title", "Visual Suggestions", "All"],
|
| 391 |
+
key=f"enhance_type_{i}"
|
| 392 |
+
)
|
| 393 |
+
|
| 394 |
+
if st.button("β¨ Enhance with AI", key=f"enhance_slide_{i}"):
|
| 395 |
+
with st.spinner("π§ Enhancing slide content..."):
|
| 396 |
+
# Update slide with current edits first
|
| 397 |
+
updated_slide = {
|
| 398 |
+
'title': slide_title,
|
| 399 |
+
'purpose': slide_purpose,
|
| 400 |
+
'key_points': key_points.split("\n") if "\n" in key_points else [key_points] if key_points else [],
|
| 401 |
+
'visual_elements': visual_elements.split("\n") if "\n" in visual_elements else [visual_elements] if visual_elements else []
|
| 402 |
+
}
|
| 403 |
+
|
| 404 |
+
try:
|
| 405 |
+
from agents import enhance_slide_component
|
| 406 |
+
|
| 407 |
+
# Apply enhancement based on selected type
|
| 408 |
+
if enhancement_type in ["Content", "All"]:
|
| 409 |
+
updated_slide, result = enhance_slide_component(updated_slide, "content")
|
| 410 |
+
|
| 411 |
+
if enhancement_type in ["Title", "All"]:
|
| 412 |
+
updated_slide, result = enhance_slide_component(updated_slide, "title")
|
| 413 |
+
|
| 414 |
+
if enhancement_type in ["Visual Suggestions", "All"]:
|
| 415 |
+
updated_slide, result = enhance_slide_component(updated_slide, "visuals")
|
| 416 |
+
|
| 417 |
+
# Update the storyboard with enhanced slide
|
| 418 |
+
st.session_state.storyboard[i] = updated_slide
|
| 419 |
+
st.success("Slide enhanced with AI!")
|
| 420 |
+
st.rerun()
|
| 421 |
+
except Exception as e:
|
| 422 |
+
st.error(f"Error enhancing slide: {str(e)}")
|
| 423 |
+
|
| 424 |
+
# Web search enhancement - MOVED OUT OF NESTED EXPANDER
|
| 425 |
+
if perplexity_key:
|
| 426 |
+
st.write("##### π Web Search Enhancement")
|
| 427 |
+
search_query = st.text_input(
|
| 428 |
+
"Search Query",
|
| 429 |
+
value=f"latest information about {slide_title}",
|
| 430 |
+
key=f"search_query_{i}"
|
| 431 |
+
)
|
| 432 |
|
| 433 |
+
if st.button("π Search & Enhance", key=f"search_enhance_{i}"):
|
| 434 |
+
# Update slide with current edits first
|
| 435 |
+
updated_slide = {
|
| 436 |
+
'title': slide_title,
|
| 437 |
+
'purpose': slide_purpose,
|
| 438 |
+
'key_points': key_points.split("\n") if "\n" in key_points else [key_points] if key_points else [],
|
| 439 |
+
'visual_elements': visual_elements.split("\n") if "\n" in visual_elements else [visual_elements] if visual_elements else []
|
| 440 |
+
}
|
| 441 |
+
|
| 442 |
+
try:
|
| 443 |
+
# Enhance with web search
|
| 444 |
+
enhanced_slide = ai_manager.enhance_with_web_search(updated_slide, search_query)
|
| 445 |
|
| 446 |
+
# Update the storyboard
|
| 447 |
+
st.session_state.storyboard[i] = enhanced_slide
|
| 448 |
+
st.success("Slide enhanced with web search results!")
|
| 449 |
+
st.rerun()
|
| 450 |
+
except Exception as e:
|
| 451 |
+
st.error(f"Error enhancing with web search: {str(e)}")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 452 |
|
| 453 |
# Update storyboard with edits
|
| 454 |
edited_slide = {
|