Spaces:
Sleeping
Sleeping
# Home.py (Main application homepage) | |
import streamlit as st | |
import os | |
from dotenv import load_dotenv | |
import google.generativeai as genai | |
import sys | |
# Add project root to path for imports | |
sys.path.append(os.path.dirname(__file__)) | |
# Apply custom styling for Huggingface Space compatibility | |
try: | |
from .streamlit.custom import init as apply_custom_styling | |
apply_custom_styling() | |
except (ImportError, ModuleNotFoundError): | |
# Fallback for when running locally or if custom styling fails | |
pass | |
# Load environment variables | |
load_dotenv() | |
# Initialize session state if needed | |
if "page_viewed" not in st.session_state: | |
st.session_state.page_viewed = True | |
# Page setup - set this consistently across all pages | |
st.set_page_config( | |
page_title="AI Financial Dashboard", | |
page_icon="📊", | |
layout="wide", | |
initial_sidebar_state="expanded" | |
) | |
# Clear any previous runs to avoid stacking UI elements | |
if hasattr(st, 'empty'): | |
placeholder = st.empty() | |
with placeholder.container(): | |
# Application title | |
st.title("📊 AI Financial Dashboard v2.0") | |
# Display application information | |
st.markdown(""" | |
## Welcome to AI Financial Dashboard | |
This is an intelligent financial analysis application using AI to help you make smarter investment decisions. | |
### Main Features: | |
1. **📰 Daily News Report** - Summary of the latest financial news: | |
- Compilation of latest financial news | |
- Categorized by topic | |
- Daily market updates | |
| |
2. **📄 Stock Analysis Report** - In-depth analysis of a specific stock: | |
- Comprehensive analysis of a specific stock | |
- Data collection from multiple sources | |
- Generate in-depth reports with AI evaluation | |
| |
3. **💬 Stock Chatbot** - Chat with AI Financial Analyst: | |
- Search for stock information | |
- View price charts | |
- Convert currencies | |
### How to Use: | |
Use the navigation bar on the left to switch between different features of the application. | |
""") | |
# Display API connection status | |
st.sidebar.title("Connection Status") | |
# Check API keys | |
api_keys = { | |
"GEMINI_API_KEY": os.getenv("GEMINI_API_KEY"), | |
"ALPHA_VANTAGE_API_KEY": os.getenv("ALPHA_VANTAGE_API_KEY"), | |
"NEWS_API_KEY": os.getenv("NEWS_API_KEY"), | |
"MARKETAUX_API_KEY": os.getenv("MARKETAUX_API_KEY"), | |
"TWELVEDATA_API_KEY": os.getenv("TWELVEDATA_API_KEY") | |
} | |
# Display status of each API | |
for api_name, api_key in api_keys.items(): | |
if api_key: | |
st.sidebar.success(f"✅ {api_name.split('_KEY')[0].replace('_', ' ')}") | |
else: | |
st.sidebar.error(f"❌ {api_name.split('_KEY')[0].replace('_', ' ')}") | |
# Display project information | |
st.sidebar.markdown("---") | |
st.sidebar.markdown(""" | |
### Project Information | |
- **Version**: 2.0 | |
- **Update**: In-depth analysis report feature | |
""") |