-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathtest_all_examples.py
More file actions
77 lines (59 loc) · 1.77 KB
/
test_all_examples.py
File metadata and controls
77 lines (59 loc) · 1.77 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
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import sys
import os
# Add output_graphs directory to path
sys.path.append(os.path.join(os.path.dirname(__file__), 'output_graphs'))
from simple_chat import create_graph as create_simple_chat
from retrieval_qa import create_graph as create_retrieval_qa
def test_simple_chat():
print("\n=== Testing Simple Chat ===\n")
app = create_simple_chat()
test_input = {
"input": "What is LangGraph?"
}
print("Input:", test_input)
print("\nProcessing...\n")
try:
result = app.invoke(test_input)
print("Output:", result)
print("\nStatus: Success ✅")
return True
except Exception as e:
print(f"Error: {str(e)}")
print("\nStatus: Failed ❌")
return False
def test_retrieval_qa():
print("\n=== Testing Retrieval QA ===\n")
app = create_retrieval_qa()
test_input = {
"input": "What is LangGraph and what are its key features?"
}
print("Input:", test_input)
print("\nProcessing...\n")
try:
result = app.invoke(test_input)
print("Output:", result)
print("\nStatus: Success ✅")
return True
except Exception as e:
print(f"Error: {str(e)}")
print("\nStatus: Failed ❌")
return False
def main():
print("Running all example tests...")
success_count = 0
total_tests = 2
if test_simple_chat():
success_count += 1
if test_retrieval_qa():
success_count += 1
print(f"\nTest Summary: {success_count}/{total_tests} tests passed")
if success_count == total_tests:
print("\nAll tests passed! 🎉")
return 0
else:
print("\nSome tests failed. 😢")
return 1
if __name__ == "__main__":
sys.exit(main())