-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
94 lines (70 loc) · 2.25 KB
/
main.py
File metadata and controls
94 lines (70 loc) · 2.25 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
import os
from dotenv import load_dotenv
from pathlib import Path
import traceback
env_path = Path(__file__).parent / "key.env"
load_dotenv(dotenv_path=env_path)
from graph.runner import run_with_interrupt, run_with_stream
from tools.tool_registry import ToolRegistry, register_all_tools
def test_stream():
"""Stream 모드 기본 테스트"""
print("=" * 70)
print("🧪 TEST 1: Stream 모드 (간단한 질문)")
print("=" * 70)
result = run_with_stream(
"2 + 3은 얼마야?",
session_id="test-stream-1"
)
print("\n✅ 최종 결과:")
print(result)
print("\n" + "=" * 70 + "\n")
def test_interrupt():
"""Interrupt 모드 테스트"""
print("=" * 70)
print("🧪 TEST 2: Interrupt 모드 (Tool 호출)")
print("=" * 70)
result = run_with_interrupt(
"구글에서 'LangGraph'를 검색해줘",
session_id="test-interrupt-1"
)
if result:
print("\n✅ 최종 결과:")
print(result[:200] + "..." if len(result) > 200 else result)
else:
print("\n❌ 사용자가 취소했습니다.")
print("\n" + "=" * 70 + "\n")
def test_tool_registry():
"""Tool Registry 확인"""
print("=" * 70)
print("🧪 TEST 0: Tool Registry 확인")
print("=" * 70)
registry = ToolRegistry()
register_all_tools(registry)
print(f"\n등록된 Tool ({len(registry._tools)}개):")
for name, spec in registry._tools.items():
print(f" - {name}: {spec.description[:50]}...")
print("\n" + "=" * 70 + "\n")
def main():
"""메인 테스트 함수"""
print("\n🚀 LangGraph 테스트 시작\n")
# 0. Tool Registry 확인
test_tool_registry()
# 1. Stream 모드 테스트
try:
test_stream()
except Exception as e:
print(f"❌ Stream 테스트 실패: {e}")
print("\n상세 에러:")
traceback.print_exc()
print()
# 2. Interrupt 모드 테스트
try:
test_interrupt()
except Exception as e:
print(f"❌ Interrupt 테스트 실패: {e}")
print("\n상세 에러:")
traceback.print_exc()
print()
print("✅ 모든 테스트 완료!")
if __name__ == "__main__":
main()