forked from BexTuychiev/investment-committee-langgraph
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathmain.py
More file actions
79 lines (60 loc) · 2.23 KB
/
main.py
File metadata and controls
79 lines (60 loc) · 2.23 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
#!/usr/bin/env python3
"""
Investment Committee Multi-Agent System
A command-line interface for analyzing stock investments using a multi-agent system
with bull, bear, and chairman agents that debate and make investment decisions.
"""
import sys
from src.agents import create_investment_supervisor
from src.utils import pretty_print_messages
def print_welcome():
"""Print welcome message and system description"""
print("💼 INVESTMENT COMMITTEE SYSTEM")
print("=" * 50)
print("🐂 Bull Agent: Finds reasons to BUY")
print("🐻 Bear Agent: Finds reasons to AVOID")
print("🎯 Chairman: Makes final decision")
print("=" * 50)
def analyze_stock(supervisor, stock_symbol):
"""Analyze a stock using the investment committee"""
print(f"\n📈 ANALYZING: {stock_symbol.upper()}")
print("-" * 30)
user_query = f"Should I invest in {stock_symbol} stock? I want to hear both bullish and bearish arguments before making a decision."
for chunk in supervisor.stream(
{
"messages": [
{
"role": "user",
"content": user_query,
}
]
},
):
pretty_print_messages(chunk, last_message=True)
def main():
"""Main application entry point"""
print_welcome()
# Create the investment supervisor
print("🔄 Initializing investment committee...")
supervisor = create_investment_supervisor()
print("✅ Committee ready!\n")
# Interactive mode
while True:
try:
stock_input = input("Enter stock symbol (or 'quit' to exit): ").strip()
if stock_input.lower() in ["quit", "exit", "q"]:
print("\n👋 Goodbye! Happy investing!")
break
if not stock_input:
print("Please enter a valid stock symbol.")
continue
analyze_stock(supervisor, stock_input)
print("\n" + "=" * 50)
except KeyboardInterrupt:
print("\n\n👋 Goodbye! Happy investing!")
sys.exit(0)
except Exception as e:
print(f"\n❌ Error: {e}")
print("Please try again with a different stock symbol.")
if __name__ == "__main__":
main()