Navada25 commited on
Commit
cb936c7
Β·
verified Β·
1 Parent(s): 54a17ba

Update app.py - Voice Streaming & AI Coaching Features

Browse files
Files changed (1) hide show
  1. app.py +130 -1
app.py CHANGED
@@ -26,6 +26,9 @@ from document_templates import DocumentTemplateGenerator # Document template ge
26
  from financial_data_integration import FinancialDataIntegrator # Real-time financial data
27
  from document_intelligence import DocumentIntelligenceEngine # AI document intelligence
28
  from advanced_analytics import AdvancedAnalyticsDashboard # Advanced analytics
 
 
 
29
  print("DEBUG: Importing chainlit", flush=True)
30
  import chainlit as cl # Chainlit framework for building conversational AI interfaces
31
  print("DEBUG: Chainlit imported", flush=True)
@@ -8439,7 +8442,133 @@ Look for startups with larger radar areas and balanced performance across dimens
8439
  return
8440
 
8441
  # =============================
8442
- # ROUTE 13: AI-POWERED Q&A WITH MEMORY & PERSONA (DEFAULT)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
8443
  # =============================
8444
  # If no specific pattern matched, use GPT-4 for natural language response
8445
 
 
26
  from financial_data_integration import FinancialDataIntegrator # Real-time financial data
27
  from document_intelligence import DocumentIntelligenceEngine # AI document intelligence
28
  from advanced_analytics import AdvancedAnalyticsDashboard # Advanced analytics
29
+ from voice_streaming import VoiceStreamingManager, VoiceUIManager # OpenAI voice streaming
30
+ from startup_coach_personas import StartupCoachPersonas, PersonaUIManager # AI coaching personas
31
+ from market_intelligence_dashboard import MarketIntelligenceDashboard # Market intelligence
32
  print("DEBUG: Importing chainlit", flush=True)
33
  import chainlit as cl # Chainlit framework for building conversational AI interfaces
34
  print("DEBUG: Chainlit imported", flush=True)
 
8442
  return
8443
 
8444
  # =============================
8445
+ # ROUTE 14: VOICE STREAMING & CONVERSATION
8446
+ # =============================
8447
+ if any(keyword in user_input for keyword in ["voice chat", "start voice", "voice streaming", "talk to", "voice conversation"]):
8448
+ # Initialize voice streaming interface
8449
+ voice_ui = VoiceUIManager()
8450
+ voice_interface = await voice_ui.create_voice_interface()
8451
+
8452
+ await cl.Message(
8453
+ content="🎀 **Voice Conversation Mode**\n\n"
8454
+ "Choose your AI coaching persona and start a voice conversation!\n\n"
8455
+ "**Available Features:**\n"
8456
+ "β€’ Real-time voice conversation with OpenAI\n"
8457
+ "β€’ Multiple specialized coaching personas\n"
8458
+ "β€’ Audio visualization and recording\n"
8459
+ "β€’ Conversation summaries\n\n"
8460
+ "Click the microphone button below to start:",
8461
+ elements=[cl.Html(content=voice_interface)]
8462
+ ).send()
8463
+ return
8464
+
8465
+ # Handle voice-related messages from JavaScript interface
8466
+ if hasattr(message, 'type') and message.type in ['voice_audio', 'switch_persona', 'get_summary']:
8467
+ voice_ui = VoiceUIManager()
8468
+ response = await voice_ui.handle_voice_message(message.type, message.content)
8469
+
8470
+ if response.get('status') == 'success':
8471
+ await cl.Message(content=f"βœ… {response.get('message', 'Voice command processed')}").send()
8472
+ else:
8473
+ await cl.Message(content=f"❌ {response.get('message', 'Voice command failed')}").send()
8474
+ return
8475
+
8476
+ # =============================
8477
+ # ROUTE 15: AI STARTUP COACHING PERSONAS
8478
+ # =============================
8479
+ if any(keyword in user_input for keyword in ["coaching", "advisor", "persona", "coach", "startup coach", "choose coach"]):
8480
+ # Initialize persona manager
8481
+ persona_ui = PersonaUIManager()
8482
+ coach_personas = StartupCoachPersonas()
8483
+
8484
+ if "switch" in user_input or "change" in user_input:
8485
+ # Handle persona switching
8486
+ personas = coach_personas.get_available_personas()
8487
+ persona_list = "\n".join([f"β€’ **{p['name']}** - {', '.join(p['expertise'][:2])}"
8488
+ for p in personas.values()])
8489
+
8490
+ await cl.Message(
8491
+ content=f"🎯 **Available Startup Coaches:**\n\n{persona_list}\n\n"
8492
+ "Which coach would you like to work with? Just mention their name or expertise area."
8493
+ ).send()
8494
+ return
8495
+
8496
+ # Show persona selector interface
8497
+ persona_interface = persona_ui.create_persona_selector()
8498
+
8499
+ await cl.Message(
8500
+ content="🎯 **AI-Powered Startup Coaching**\n\n"
8501
+ "Choose from our specialized AI coaches, each with deep expertise in different areas of startup development:",
8502
+ elements=[cl.Html(content=persona_interface)]
8503
+ ).send()
8504
+ return
8505
+
8506
+ # Handle persona selection from interface
8507
+ if hasattr(message, 'type') and message.type == 'select_persona':
8508
+ coach_personas = StartupCoachPersonas()
8509
+ persona_id = message.content.get('persona_id')
8510
+ startup_context = message.content.get('startup_context', {})
8511
+
8512
+ session_result = await coach_personas.initialize_coaching_session(persona_id, startup_context)
8513
+
8514
+ if session_result.get('status') == 'success':
8515
+ persona = session_result['persona']
8516
+ welcome = session_result['welcome_message']
8517
+
8518
+ # Store session in Chainlit user session
8519
+ cl.user_session.set("coaching_session", session_result['session_id'])
8520
+ cl.user_session.set("current_persona", persona_id)
8521
+
8522
+ await cl.Message(
8523
+ content=f"βœ… **{persona['avatar']} {persona['name']} is now your coach!**\n\n"
8524
+ f"{welcome}\n\n"
8525
+ f"**Expertise:** {', '.join(persona['expertise'])}\n\n"
8526
+ "Ask me anything about your startup - I'm here to help!"
8527
+ ).send()
8528
+ else:
8529
+ await cl.Message(content=f"❌ Error initializing coaching session: {session_result.get('message')}").send()
8530
+ return
8531
+
8532
+ # =============================
8533
+ # ROUTE 16: MARKET INTELLIGENCE DASHBOARD
8534
+ # =============================
8535
+ if any(keyword in user_input for keyword in ["market intelligence", "market dashboard", "competitive analysis",
8536
+ "market trends", "sector analysis", "market data"]):
8537
+ # Initialize market intelligence dashboard
8538
+ market_dashboard = MarketIntelligenceDashboard()
8539
+ dashboard_interface = await market_dashboard.create_dashboard_interface()
8540
+
8541
+ await cl.Message(
8542
+ content="πŸ“Š **Market Intelligence Dashboard**\n\n"
8543
+ "Access real-time market data, competitive intelligence, and trend analysis:\n\n"
8544
+ "**Features:**\n"
8545
+ "β€’ Sector performance analysis\n"
8546
+ "β€’ Competitive landscape mapping\n"
8547
+ "β€’ Market trend identification\n"
8548
+ "β€’ Investment theme analysis\n"
8549
+ "β€’ Real-time data visualization\n\n"
8550
+ "Use the controls below to analyze your market:",
8551
+ elements=[cl.Html(content=dashboard_interface)]
8552
+ ).send()
8553
+ return
8554
+
8555
+ # Handle dashboard requests from interface
8556
+ if hasattr(message, 'type') and message.type == 'dashboard_request':
8557
+ market_dashboard = MarketIntelligenceDashboard()
8558
+ request_type = message.content.get('request_type')
8559
+ data = message.content.get('data', {})
8560
+
8561
+ response = await market_dashboard.handle_dashboard_request(request_type, data)
8562
+
8563
+ if response.get('status') == 'success':
8564
+ # Send the response back to the dashboard
8565
+ await cl.Message(content="πŸ“Š Dashboard updated with latest data.").send()
8566
+ else:
8567
+ await cl.Message(content=f"❌ Dashboard error: {response.get('message')}").send()
8568
+ return
8569
+
8570
+ # =============================
8571
+ # ROUTE 17: AI-POWERED Q&A WITH MEMORY & PERSONA (DEFAULT)
8572
  # =============================
8573
  # If no specific pattern matched, use GPT-4 for natural language response
8574