|
def render_ai_financial_advisor(startup_data): |
|
""" |
|
Render the AI financial advisor page with voice chat capabilities. |
|
|
|
This feature provides conversational financial guidance to founders through a |
|
natural chat interface with both text and voice responses. |
|
""" |
|
st.markdown("<h1 class='main-header'>AI Financial Advisor</h1>", unsafe_allow_html=True) |
|
st.markdown("<p class='sub-header'>Get expert financial guidance through our AI-powered advisor</p>", unsafe_allow_html=True) |
|
|
|
|
|
with st.expander("ℹ️ How AI powers your financial advisor"): |
|
st.markdown(""" |
|
### How AI Powers Your Financial Advisor |
|
|
|
Our AI financial advisor combines advanced language models with financial expertise: |
|
|
|
- **Natural Language Understanding**: The system interprets complex financial questions in plain English |
|
- **Domain-Specific Knowledge**: Our AI is trained on startup finance, venture capital, and financial modeling |
|
- **Context-Aware Responses**: The advisor takes into account your specific financial situation and history |
|
- **Voice Synthesis**: ElevenLabs voice technology creates natural, high-quality voice responses |
|
- **Customized Guidance**: AI tailors advice specifically to your stage, industry, and financial position |
|
|
|
This gives founders 24/7 access to high-quality financial guidance without the high cost of consultants. |
|
""") |
|
|
|
|
|
st.markdown("<div style='background-color: #f8f9fa; padding: 20px; border-radius: 10px; margin-bottom: 20px;'>", unsafe_allow_html=True) |
|
|
|
|
|
st.subheader("Chat with your Financial Advisor") |
|
|
|
|
|
if 'chat_history' not in st.session_state: |
|
st.session_state.chat_history = [ |
|
{"role": "assistant", "content": "Hi there! I'm your AI financial advisor. How can I help with your startup's finances today?"} |
|
] |
|
|
|
|
|
for message in st.session_state.chat_history: |
|
if message["role"] == "user": |
|
st.markdown(f"<div style='background-color: #e6f7ff; padding: 10px; border-radius: 10px; margin-bottom: 10px;'><strong>You:</strong> {message['content']}</div>", unsafe_allow_html=True) |
|
else: |
|
st.markdown(f"<div style='background-color: #f0f7ff; padding: 10px; border-radius: 10px; margin-bottom: 10px;'><strong>Financial Advisor:</strong> {message['content']}</div>", unsafe_allow_html=True) |
|
|
|
|
|
if 'audio' in message and message['audio']: |
|
st.audio(message['audio'], format='audio/mp3') |
|
|
|
|
|
col1, col2 = st.columns([5, 1]) |
|
|
|
with col1: |
|
user_input = st.text_input("Ask a financial question", key="user_question") |
|
|
|
with col2: |
|
use_voice = st.checkbox("Enable voice", value=True) |
|
|
|
|
|
st.markdown("### Common Questions") |
|
question_cols = st.columns(3) |
|
|
|
common_questions = [ |
|
"How much runway do we have at our current burn rate?", |
|
"Should we increase our marketing spend given our growth rate?", |
|
"When should we start preparing for our next fundraising round?", |
|
"How can we optimize our burn rate without impacting growth?", |
|
"What metrics should we focus on improving right now?", |
|
"How do our unit economics compare to similar startups?" |
|
] |
|
|
|
selected_question = None |
|
|
|
for i, question in enumerate(common_questions): |
|
with question_cols[i % 3]: |
|
if st.button(question, key=f"q_{i}"): |
|
selected_question = question |
|
|
|
|
|
if user_input or selected_question: |
|
question = user_input or selected_question |
|
|
|
|
|
st.session_state.chat_history.append({"role": "user", "content": question}) |
|
|
|
|
|
response = get_advisory_guidance(question, startup_data) |
|
|
|
|
|
audio_data = None |
|
if use_voice: |
|
audio_data = generate_voice_response(response) |
|
|
|
|
|
st.session_state.chat_history.append({ |
|
"role": "assistant", |
|
"content": response, |
|
"audio": audio_data |
|
}) |
|
|
|
|
|
st.experimental_rerun() |
|
|
|
st.markdown("</div>", unsafe_allow_html=True) |
|
|
|
|
|
st.subheader("Advanced Tools") |
|
|
|
tool_cols = st.columns(3) |
|
|
|
with tool_cols[0]: |
|
st.markdown(""" |
|
<div style='background-color: white; padding: 15px; border-radius: 10px; height: 200px; box-shadow: 0 4px 6px rgba(0,0,0,0.1);'> |
|
<h4>Financial Model Review</h4> |
|
<p>Upload your financial model for AI analysis and recommendations.</p> |
|
<div style='position: absolute; bottom: 15px;'> |
|
<input type='file' disabled/> |
|
</div> |
|
</div> |
|
""", unsafe_allow_html=True) |
|
|
|
with tool_cols[1]: |
|
st.markdown(""" |
|
<div style='background-color: white; padding: 15px; border-radius: 10px; height: 200px; box-shadow: 0 4px 6px rgba(0,0,0,0.1);'> |
|
<h4>Investor Pitch Review</h4> |
|
<p>Get AI feedback on your investor pitch deck and financial projections.</p> |
|
<div style='position: absolute; bottom: 15px;'> |
|
<input type='file' disabled/> |
|
</div> |
|
</div> |
|
""", unsafe_allow_html=True) |
|
|
|
with tool_cols[2]: |
|
st.markdown(""" |
|
<div style='background-color: white; padding: 15px; border-radius: 10px; height: 200px; box-shadow: 0 4px 6px rgba(0,0,0,0.1);'> |
|
<h4>Fundraising Strategy</h4> |
|
<p>Generate a customized fundraising strategy based on your metrics.</p> |
|
<div style='position: absolute; bottom: 15px;'> |
|
<button disabled>Generate Strategy</button> |
|
</div> |
|
</div> |
|
""", unsafe_allow_html=True) |
|
|
|
|
|
st.markdown(""" |
|
<div style='background-color: #e6f7ff; padding: 20px; border-radius: 10px; margin-top: 30px;'> |
|
<h3>Need more in-depth guidance?</h3> |
|
<p>Book a dedicated session with our AI financial advisor for comprehensive analysis and personalized advice.</p> |
|
<a href='#book-a-session'><button>Book a Session</button></a> |
|
</div> |
|
""", unsafe_allow_html=True) |
|
|
|
def get_advisory_guidance(question, financial_data): |
|
"""Get strategic guidance for a startup question.""" |
|
prompt = f""" |
|
You are a strategic financial advisor for startups. A founder asks: |
|
"{question}" |
|
|
|
Here's their current financial situation: |
|
- Stage: {financial_data['stage']} |
|
- Current cash: ${financial_data['cash']} |
|
- Monthly burn rate: ${financial_data['burn_rate']} |
|
- Monthly revenue: ${financial_data['revenue']} |
|
- Monthly growth rate: {financial_data['growth_rate'] * 100}% |
|
- Last funding: {financial_data['last_funding']} |
|
- Team size: {financial_data['employees']} |
|
|
|
Provide detailed, actionable advice addressing their question. Include: |
|
1. Clear assessment of their current situation |
|
2. 3-5 specific, actionable recommendations with expected outcomes |
|
3. Relevant metrics they should track |
|
4. Industry benchmarks for comparison |
|
5. Timeline for implementation and results |
|
|
|
Be specific with numbers, timeframes, and expected outcomes. |
|
""" |
|
|
|
return generate_ai_response(prompt) |
|
|
|
def generate_voice_response(text): |
|
"""Generate voice response using ElevenLabs API (simulated).""" |
|
try: |
|
|
|
|
|
|
|
|
|
audio_data = b'' |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return audio_data |
|
except Exception as e: |
|
st.warning(f"Error generating voice response: {e}") |
|
return None |
|
|