|
import streamlit as st |
|
import os |
|
|
|
|
|
|
|
from src.pages import dashboard, decision_simulator, fund_monitoring, financial_advisor |
|
from src.utils.data_processing import ( |
|
generate_sample_startup_data, |
|
generate_sample_cash_flow_data, |
|
generate_sample_transactions_data |
|
) |
|
|
|
|
|
|
|
DEFAULT_GROWTH_RATE = 0.08 |
|
DEFAULT_BURN_RATE = 85000 |
|
ENGINEER_SALARY = 10000 |
|
|
|
def main(): |
|
""" |
|
Main application entry point for Startup Finance Pilot |
|
""" |
|
|
|
st.set_page_config( |
|
page_title="StartupFinancePilot", |
|
page_icon="๐ฐ", |
|
layout="wide", |
|
initial_sidebar_state="expanded" |
|
) |
|
|
|
|
|
st.markdown(""" |
|
<style> |
|
/* Your existing CSS styles from previous implementation */ |
|
.main-header { font-size: 2.5rem; color: #0066cc; } |
|
.sub-header { font-size: 1.5rem; color: #5c5c5c; } |
|
/* Add more styles as needed */ |
|
</style> |
|
""", unsafe_allow_html=True) |
|
|
|
|
|
if 'startups' not in st.session_state: |
|
st.session_state.startups = {} |
|
|
|
if 'current_startup' not in st.session_state: |
|
st.session_state.current_startup = None |
|
|
|
if 'current_page' not in st.session_state: |
|
st.session_state.current_page = 'upload' |
|
|
|
if 'insights_cache' not in st.session_state: |
|
st.session_state.insights_cache = {} |
|
|
|
|
|
sample_startup = generate_sample_startup_data() |
|
st.session_state.startups[sample_startup['name']] = { |
|
'profile': sample_startup, |
|
'cash_flow': generate_sample_cash_flow_data(), |
|
'transactions': generate_sample_transactions_data() |
|
} |
|
st.session_state.current_startup = sample_startup['name'] |
|
|
|
|
|
with st.sidebar: |
|
st.title("๐ฐ StartupFinancePilot") |
|
st.write("AI-powered financial assistant for startups") |
|
|
|
|
|
if st.session_state.startups: |
|
startup_names = list(st.session_state.startups.keys()) |
|
selected_startup = st.selectbox( |
|
"Choose Startup", |
|
startup_names, |
|
index=startup_names.index(st.session_state.current_startup) |
|
) |
|
|
|
st.session_state.current_startup = selected_startup |
|
|
|
|
|
startup_data = st.session_state.startups[selected_startup]['profile'] |
|
st.markdown(f""" |
|
**Stage:** {startup_data['stage']} |
|
**Cash:** ${startup_data['cash']:,} |
|
**Monthly Burn:** ${startup_data['burn_rate']:,} |
|
**Monthly Revenue:** ${startup_data['revenue']:,} |
|
""") |
|
|
|
|
|
st.markdown("<hr>", unsafe_allow_html=True) |
|
|
|
page_options = { |
|
"๐ Financial Dashboard": "dashboard", |
|
"๐ฎ Decision Simulator": "simulator", |
|
"๐ต๏ธ Fund Monitoring": "monitoring", |
|
"๐ค AI Financial Advisor": "advisor" |
|
} |
|
|
|
for label, page_key in page_options.items(): |
|
if st.button(label, use_container_width=True): |
|
st.session_state.current_page = page_key |
|
st.experimental_rerun() |
|
|
|
|
|
if st.session_state.current_page == 'dashboard': |
|
dashboard.render_financial_dashboard( |
|
st.session_state.startups[st.session_state.current_startup]['profile'], |
|
st.session_state.startups[st.session_state.current_startup]['cash_flow'] |
|
) |
|
elif st.session_state.current_page == 'simulator': |
|
decision_simulator.render_decision_simulator( |
|
st.session_state.startups[st.session_state.current_startup]['profile'] |
|
) |
|
elif st.session_state.current_page == 'monitoring': |
|
fund_monitoring.render_fund_monitoring( |
|
st.session_state.startups[st.session_state.current_startup]['transactions'] |
|
) |
|
elif st.session_state.current_page == 'advisor': |
|
financial_advisor.render_ai_financial_advisor( |
|
st.session_state.startups[st.session_state.current_startup]['profile'] |
|
) |
|
|
|
def validate_gemini_api_key(): |
|
""" |
|
Validate the Google Generative AI API key |
|
|
|
Returns: |
|
bool: True if API key is valid, False otherwise |
|
""" |
|
try: |
|
import google.generativeai as genai |
|
api_key = os.getenv('GOOGLE_API_KEY') |
|
|
|
if not api_key: |
|
st.error("๐จ Google API Key not found. Please set GOOGLE_API_KEY in your .env file.") |
|
return False |
|
|
|
genai.configure(api_key=api_key) |
|
model = genai.GenerativeModel('gemini-pro') |
|
|
|
|
|
test_response = model.generate_content("Hello, can you confirm the API is working?") |
|
return True |
|
except Exception as e: |
|
st.error(f"๐จ Error validating API key: {e}") |
|
return False |
|
|
|
if __name__ == "__main__": |
|
|
|
if validate_gemini_api_key(): |
|
main() |
|
else: |
|
st.warning("Please set up your Google Generative AI API key to use the application.") |
|
|