-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_skills.py
More file actions
88 lines (71 loc) · 2.72 KB
/
Copy pathtest_skills.py
File metadata and controls
88 lines (71 loc) · 2.72 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
#!/usr/bin/env python3
"""
Test Skills System
测试 skills 系统加载和调用
"""
import asyncio
import sys
import os
# Add project root to path
sys.path.insert(0, os.path.dirname(os.path.abspath(__file__)))
from keytao_bot.skills import SkillsManager
async def test_skills_loading():
"""Test loading skills"""
print("=" * 60)
print("Testing Skills System")
print("=" * 60)
# Create skills manager
manager = SkillsManager()
# Load all skills
print("\n1️⃣ Loading skills...")
manager.load_all_skills()
# Check loaded tools
tools = manager.get_tools()
print(f"\n✅ Loaded {len(tools)} tools")
for i, tool in enumerate(tools, 1):
func = tool.get("function", {})
print(f" {i}. {func.get('name', 'Unknown')} - {func.get('description', 'No description')}")
# Test keytao lookup by code
print("\n2️⃣ Testing keytao_lookup_by_code...")
lookup_func = manager.get_tool_function("keytao_lookup_by_code")
if lookup_func:
result = await lookup_func(code="nau")
print(f" Query result for 'nau':")
if result.get("success"):
for phrase in result.get("phrases", [])[:3]:
print(f" • {phrase['word']} ({phrase['code']}) [权重: {phrase['weight']}]")
else:
print(f" ❌ Error: {result.get('error')}")
else:
print(" ❌ Function not found")
# Test keytao lookup by word
print("\n3️⃣ Testing keytao_lookup_by_word...")
lookup_func = manager.get_tool_function("keytao_lookup_by_word")
if lookup_func:
result = await lookup_func(word="你好")
print(f" Query result for '你好':")
if result.get("success"):
for phrase in result.get("phrases", [])[:3]:
print(f" • {phrase['word']} → {phrase['code']} [权重: {phrase['weight']}]")
else:
print(f" ❌ Error: {result.get('error')}")
else:
print(" ❌ Function not found")
# Test web search
print("\n4️⃣ Testing web_search...")
search_func = manager.get_tool_function("web_search")
if search_func:
result = await search_func(query="NoneBot2 官网", max_results=3)
print(" Query result for 'NoneBot2 官网':")
if result.get("success"):
for item in result.get("results", [])[:3]:
print(f" • {item['title']} -> {item['url']}")
else:
print(f" ❌ Error: {result.get('error')}")
else:
print(" ❌ Function not found")
print("\n" + "=" * 60)
print("✅ Skills system test completed")
print("=" * 60)
if __name__ == "__main__":
asyncio.run(test_skills_loading())