Update app.py
Browse files
app.py
CHANGED
@@ -6,14 +6,66 @@ from datetime import datetime, timedelta, date
|
|
6 |
import time
|
7 |
import io
|
8 |
import base64
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
9 |
|
10 |
-
|
11 |
-
#
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
17 |
|
18 |
# Constants
|
19 |
DEFAULT_GROWTH_RATE = 0.08 # 8% monthly growth
|
@@ -464,45 +516,50 @@ def create_sidebar():
|
|
464 |
if st.button("🤖 AI Financial Advisor", use_container_width=True):
|
465 |
switch_page('advisor')
|
466 |
|
467 |
-
|
468 |
def main():
|
469 |
-
#
|
470 |
-
|
471 |
|
472 |
-
#
|
473 |
-
|
474 |
-
|
475 |
-
render_upload_page()
|
476 |
-
return
|
477 |
|
478 |
-
#
|
479 |
-
|
480 |
-
|
481 |
-
|
482 |
-
|
483 |
-
|
484 |
-
|
485 |
-
|
486 |
-
|
487 |
-
|
488 |
-
|
489 |
-
|
490 |
-
|
491 |
-
render_decision_simulator
|
492 |
-
|
493 |
-
|
494 |
-
|
495 |
-
|
496 |
-
|
497 |
-
|
498 |
-
|
499 |
-
|
500 |
-
|
501 |
-
|
502 |
-
|
503 |
-
|
504 |
-
|
505 |
-
)
|
|
|
|
|
|
|
|
|
|
|
|
|
506 |
|
507 |
if __name__ == "__main__":
|
508 |
main()
|
|
|
|
6 |
import time
|
7 |
import io
|
8 |
import base64
|
9 |
+
import plotly.express as px
|
10 |
+
import plotly.graph_objects as go
|
11 |
+
from datetime import datetime, timedelta, date
|
12 |
+
import time
|
13 |
+
import json
|
14 |
+
import google.generativeai as genai
|
15 |
+
from google.generativeai.types import HarmCategory, HarmBlockThreshold
|
16 |
+
|
17 |
+
|
18 |
+
# Setup AI Services
|
19 |
+
def setup_genai():
|
20 |
+
"""Initialize and configure Google's Generative AI and list available models"""
|
21 |
+
try:
|
22 |
+
# Try getting API key from Streamlit secrets first
|
23 |
+
if 'GOOGLE_API_KEY' in st.secrets:
|
24 |
+
api_key = st.secrets['GOOGLE_API_KEY']
|
25 |
+
# Fall back to environment variable
|
26 |
+
elif 'GOOGLE_API_KEY' in os.environ:
|
27 |
+
api_key = os.environ['GOOGLE_API_KEY']
|
28 |
+
else:
|
29 |
+
st.warning("Google API key not found. Using simulated AI responses.")
|
30 |
+
st.session_state.gemini_model = "gemini-1.5-pro"
|
31 |
+
return False
|
32 |
+
|
33 |
+
genai.configure(api_key=api_key)
|
34 |
+
|
35 |
+
# Import pages
|
36 |
+
from pages.dashboard_page import render_financial_dashboard, get_runway_analysis, get_fundraising_readiness_analysis
|
37 |
+
from pages.decision_simulator import render_decision_simulator, get_decision_analysis
|
38 |
+
from pages.fund_monitoring import render_fund_monitoring, get_fraud_analysis
|
39 |
+
from pages.financial_advisor import render_ai_financial_advisor, get_advisory_guidance, generate_voice_response
|
40 |
+
from pages.book_session import render_book_session
|
41 |
+
|
42 |
+
# Initialize page configuration
|
43 |
+
st.set_page_config(
|
44 |
+
page_title="StartupFinancePilot",
|
45 |
+
page_icon="💰",
|
46 |
+
layout="wide",
|
47 |
+
initial_sidebar_state="expanded"
|
48 |
+
)
|
49 |
|
50 |
+
|
51 |
+
# Initialize session state variables
|
52 |
+
if 'booked_sessions' not in st.session_state:
|
53 |
+
st.session_state.booked_sessions = []
|
54 |
+
if 'chat_history' not in st.session_state:
|
55 |
+
st.session_state.chat_history = []
|
56 |
+
if 'audio_response' not in st.session_state:
|
57 |
+
st.session_state.audio_response = None
|
58 |
+
if 'insights_cache' not in st.session_state:
|
59 |
+
st.session_state.insights_cache = {}
|
60 |
+
if 'gemini_model' not in st.session_state:
|
61 |
+
st.session_state.gemini_model = None
|
62 |
+
if 'current_page' not in st.session_state:
|
63 |
+
st.session_state.current_page = "Financial Dashboard"
|
64 |
+
|
65 |
+
from pages.dashboard import render_financial_dashboard
|
66 |
+
from pages.decision_simulator import render_decision_simulator
|
67 |
+
from pages.fund_monitoring import render_fund_monitoring
|
68 |
+
from pages.advisor import render_ai_financial_advisor
|
69 |
|
70 |
# Constants
|
71 |
DEFAULT_GROWTH_RATE = 0.08 # 8% monthly growth
|
|
|
516 |
if st.button("🤖 AI Financial Advisor", use_container_width=True):
|
517 |
switch_page('advisor')
|
518 |
|
519 |
+
|
520 |
def main():
|
521 |
+
# Load sample data
|
522 |
+
startup_data, cash_flow_df, transactions_df = load_sample_data()
|
523 |
|
524 |
+
# Create sidebar
|
525 |
+
st.sidebar.title("StartupFinancePilot")
|
526 |
+
st.sidebar.image("https://img.freepik.com/premium-vector/business-finance-analytics-logo-design-vector-template_67715-552.jpg", width=150)
|
|
|
|
|
527 |
|
528 |
+
# Company profile
|
529 |
+
st.sidebar.header("Company Profile")
|
530 |
+
st.sidebar.write(f"**{startup_data['name']}**")
|
531 |
+
st.sidebar.write(f"Stage: {startup_data['stage']}")
|
532 |
+
st.sidebar.write(f"Founded: {startup_data['founded']}")
|
533 |
+
st.sidebar.write(f"Employees: {startup_data['employees']}")
|
534 |
+
st.sidebar.write(f"Last Funding: {startup_data['last_funding']}")
|
535 |
+
|
536 |
+
|
537 |
+
# Navigation
|
538 |
+
st.sidebar.header("Navigation")
|
539 |
+
pages = {
|
540 |
+
"Financial Dashboard": render_financial_dashboard,
|
541 |
+
"Decision Simulator": render_decision_simulator,
|
542 |
+
"Fund Monitoring": render_fund_monitoring,
|
543 |
+
"AI Financial Advisor": render_ai_financial_advisor,
|
544 |
+
"Book a Session": render_book_session
|
545 |
+
}
|
546 |
+
|
547 |
+
# Page selection
|
548 |
+
selected_page = st.sidebar.radio("Go to", list(pages.keys()))
|
549 |
+
st.session_state.current_page = selected_page
|
550 |
+
|
551 |
+
# Render selected page
|
552 |
+
if selected_page == "Financial Dashboard":
|
553 |
+
pages[selected_page](startup_data, cash_flow_df)
|
554 |
+
elif selected_page == "Decision Simulator":
|
555 |
+
pages[selected_page](startup_data)
|
556 |
+
elif selected_page == "Fund Monitoring":
|
557 |
+
pages[selected_page](transactions_df)
|
558 |
+
elif selected_page == "AI Financial Advisor":
|
559 |
+
pages[selected_page](startup_data)
|
560 |
+
else: # Book a Session
|
561 |
+
pages[selected_page]()
|
562 |
|
563 |
if __name__ == "__main__":
|
564 |
main()
|
565 |
+
|