-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdemo.py
More file actions
71 lines (60 loc) · 2.11 KB
/
demo.py
File metadata and controls
71 lines (60 loc) · 2.11 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
"""Demo script to test the multi-agent system without user interaction."""
from langchain_core.messages import HumanMessage
from config import setup_api_keys
from graph import create_research_graph
from state import AgentState
def demo_test():
"""Run a demo test of the system."""
print("🧪 Running demo test...")
# Setup
setup_api_keys()
research_graph = create_research_graph()
# Test cases
test_cases = [
{
"location": "San Francisco, CA",
"query": "weather",
"description": "Weather-only query"
},
{
"location": "New York, NY",
"query": "news",
"description": "News-only query"
},
{
"location": "London, UK",
"query": "weather and news",
"description": "Combined query"
}
]
for i, test in enumerate(test_cases, 1):
print(f"\n{'='*50}")
print(f"Test {i}: {test['description']}")
print(f"Location: {test['location']}")
print(f"Query: {test['query']}")
print(f"{'='*50}")
# Create initial state
initial_state: AgentState = {
"messages": [HumanMessage(content=test['query'])],
"location": test['location'],
"intent": "unknown",
"weather_data": "",
"news_data": ""
}
try:
# Execute the graph
result = research_graph.invoke(initial_state)
# Display results
print(f"\n📊 Intent detected: {result['intent']}")
print(f"📍 Location resolved: {result['location']}")
if result["messages"]:
final_response = result["messages"][-1].content
print(f"\n🎯 Final Response:\n{final_response}")
else:
print("\n❌ No response generated")
except Exception as e:
print(f"\n❌ Error in test {i}: {str(e)}")
print(f"\n{'='*50}")
print("✅ Demo complete!")
if __name__ == "__main__":
demo_test()