Skip to main content
Glama

MemOS-MCP

by qinshu1109
Apache 2.0
3
  • Linux
  • Apple
test_siliconflow_embedder.py2.45 kB
#!/usr/bin/env python3 """ 测试SiliconFlow嵌入器 """ import sys from pathlib import Path # 添加src路径 sys.path.insert(0, str(Path(__file__).parent / "src")) from memos.configs.embedder import EmbedderConfigFactory from memos.embedders.factory import EmbedderFactory from usage_examples import load_env_file def test_siliconflow_embedder(): """测试SiliconFlow嵌入器""" print("🧪 测试SiliconFlow嵌入器") print("=" * 50) # 加载环境变量 load_env_file() # 创建SiliconFlow嵌入器配置 config = EmbedderConfigFactory.model_validate({ "backend": "siliconflow", "config": { "model_name_or_path": "Qwen/Qwen3-Embedding-0.6B", "model_name": "Qwen/Qwen3-Embedding-0.6B", "api_key": "sk-ygqlrgrxrypykiiskuspuahkwihhbhhjhazqokntwdzfwqdv", "api_base": "https://api.siliconflow.cn/v1", "embedding_dims": 1024 } }) print("✅ 配置创建成功") # 创建嵌入器 embedder = EmbedderFactory.from_config(config) print("✅ 嵌入器创建成功") # 测试嵌入 test_texts = [ "这是一个测试文本", "MemOS是一个智能记忆管理系统", "SiliconFlow提供高质量的AI API服务" ] print(f"🔄 正在为{len(test_texts)}个文本生成嵌入向量...") try: embeddings = embedder.embed(test_texts) print("✅ 嵌入生成成功!") print(f"📊 嵌入统计:") print(f" 文本数量: {len(test_texts)}") print(f" 嵌入向量数量: {len(embeddings)}") print(f" 向量维度: {len(embeddings[0]) if embeddings else 0}") # 显示部分嵌入向量 for i, (text, embedding) in enumerate(zip(test_texts, embeddings)): print(f"\n📝 文本 {i+1}: {text}") print(f"🔢 向量前5维: {embedding[:5]}") print(f"📏 向量长度: {len(embedding)}") return True except Exception as e: print(f"❌ 嵌入生成失败: {e}") return False if __name__ == "__main__": success = test_siliconflow_embedder() if success: print("\n🎉 SiliconFlow嵌入器测试成功!") print("现在可以在MemOS中使用SiliconFlow嵌入模型了。") else: print("\n❌ SiliconFlow嵌入器测试失败") sys.exit(1)

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/qinshu1109/memos-MCP'

If you have feedback or need assistance with the MCP directory API, please join our Discord server