-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathtest_getnote_simple.py
More file actions
74 lines (56 loc) · 2.12 KB
/
test_getnote_simple.py
File metadata and controls
74 lines (56 loc) · 2.12 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
#!/usr/bin/env python3
"""
简单测试 Get 笔记知识库调用
只获取素材列表
"""
import os
import sys
# 设置环境变量
os.environ['GETNOTE_API_KEY'] = 'ClFmzocjTPS3kA34PmKic3zsJYJ0M4gVbWzp68aLqnocWYFFTINy/htxISaZRuoTPaLmhAmbMrWEUFvvGIUStQHUHzVp+o8iQFpa'
os.environ['GETNOTE_KB_ID'] = '707AGXvn'
from mcp_tools.getnote import GetNoteAPI
def test_get_materials_list(query, category=None, limit=5):
"""测试获取素材列表"""
print(f"\n{'='*70}")
print(f"测试查询: {query}")
if category:
print(f"分类: {category}")
print(f"{'='*70}\n")
try:
# 创建客户端
client = GetNoteAPI()
# 获取素材
print(f"🔍 正在获取素材...")
materials = client.get_materials_for_topic(
topic=query,
category=category,
limit=limit
)
if not materials:
print("\n❌ 未找到相关素材\n")
return
# 显示素材列表
print(f"\n✅ 找到 {len(materials)} 条素材:\n")
for idx, material in enumerate(materials, 1):
print(f"【素材 {idx}】")
print(f" 标题: {material.get('title', '无标题')}")
print(f" 类型: {material.get('type', 'unknown')}")
print(f" 相关度: {material.get('score', 0):.4f}")
# 显示内容预览
content = material.get('content', '')
if content:
preview = content[:150].replace('\n', ' ')
print(f" 预览: {preview}...")
print()
except Exception as e:
print(f"\n❌ 测试失败: {e}")
import traceback
traceback.print_exc()
if __name__ == "__main__":
# 测试不同的查询
# 测试 1: 职场类查询
test_get_materials_list("如何提升工作效率", category="职场", limit=3)
# 测试 2: 技术类查询
test_get_materials_list("AI 技术发展", category="科技", limit=3)
# 测试 3: 不指定分类
test_get_materials_list("时间管理技巧", limit=5)