forked from patronus-ai/financebench
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathrun_app.py
More file actions
executable file
·106 lines (90 loc) · 3.36 KB
/
Copy pathrun_app.py
File metadata and controls
executable file
·106 lines (90 loc) · 3.36 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
#!/usr/bin/env python3
"""
FinDocMadeEz - AI-Powered Financial Document Analysis & Investment Strategy
Run script for the Streamlit application
"""
import os
import sys
import subprocess
from pathlib import Path
def check_dependencies():
"""Check if required dependencies are installed"""
try:
import streamlit
import pandas
import plotly
from openai import OpenAI
print("✅ All required dependencies are installed")
return True
except ImportError as e:
print(f"❌ Missing dependency: {e}")
print("Please install dependencies with: pip install -r requirements.txt")
return False
def check_env_file():
"""Check if .env file exists and has OpenRouter API key"""
env_file = Path(".env")
if not env_file.exists():
print("⚠️ .env file not found")
print("Creating .env file with placeholder...")
with open(".env", "w") as f:
f.write("# FinDocMadeEz Environment Variables\n")
f.write("# Add your OpenRouter API key here\n")
f.write("OPEN_ROUTER_API_KEY=your_openrouter_api_key_here\n")
print("📝 Please edit .env file and add your OpenRouter API key")
return False
with open(".env", "r") as f:
content = f.read()
if "your_openrouter_api_key_here" in content:
print("⚠️ Please add your OpenRouter API key to .env file")
return False
print("✅ Environment variables configured")
return True
def check_data_files():
"""Check if FinanceBench data files exist"""
data_files = [
"data/financebench_open_source.jsonl",
"data/financebench_document_information.jsonl"
]
missing_files = []
for file_path in data_files:
if not Path(file_path).exists():
missing_files.append(file_path)
if missing_files:
print(f"⚠️ Missing data files: {missing_files}")
print("Please ensure FinanceBench data is available")
return False
print("✅ FinanceBench data files found")
return True
def main():
"""Main function to run the FinDocMadeEz application"""
print("🚀 FinDocMadeEz - AI-Powered Financial Analysis")
print("=" * 50)
# Check dependencies
if not check_dependencies():
return
# Check environment
if not check_env_file():
print("⚠️ Application will run with limited functionality")
print(" Add OpenRouter API key to .env for full AI features")
# Check data files
if not check_data_files():
print("⚠️ Application will run with limited data")
print(" Ensure FinanceBench data is available for full features")
print("\n🎯 Starting FinDocMadeEz application...")
print("📊 Open your browser to http://localhost:8501")
print("🛑 Press Ctrl+C to stop the application")
print("=" * 50)
try:
# Run Streamlit app
subprocess.run([
sys.executable, "-m", "streamlit", "run", "main.py",
"--server.port", "8501",
"--server.address", "localhost",
"--browser.gatherUsageStats", "false"
])
except KeyboardInterrupt:
print("\n👋 FinDocMadeEz application stopped")
except Exception as e:
print(f"❌ Error running application: {e}")
if __name__ == "__main__":
main()