-
Notifications
You must be signed in to change notification settings - Fork 1.5k
[Question]: 可否给出一个类似mem0用法的示例 #1202
Copy link
Copy link
Open
Labels
questionFurther information is requestedFurther information is requested
Description
Your Question
您好,我是在进行openViking对接autogen,因为autogen实现了mem0系统的接入,所以参考mem0在autogen中的实现,需要使用openviking实现类似的接口。我把openviking的文档从头看到尾,没有找到类似的实现。所以想请你们给出一个类似如下mem0代码实现功能的openviking的实现。
from autogen_ext.memory.mem0 import Mem0Memory
from mem0 import Memory as Memory0
from mem0 import MemoryClient
client = Memory0.from_config(
{
"history_db_path": ":memory:",
"embedder": {
"provider": "ollama",
"config": {"model": "qwen2.5:7b", "ollama_base_url": "http://localhost:11434"}
},
"llm": {
# "provider": "mock_llm",
"provider": "ollama",
"config": {
"model": "qwen2.5:7b",
#"temperature": 0.2,
#"max_tokens": 2048,
"ollama_base_url": "http://localhost:11434"
}
}, # Use in-memory storage for testing
"vector_store": {
"provider": "chroma",
"config": {"collection_name": "test", "path": ":memory:"}
}
}
)
print("Memory initialized successfully!")
# Add something to memory
message = "User likes the color blue."
user_id="alice"
client.add([{"role": "user", "content": message}], user_id=user_id)
query_text = "What color does the user like?"
results = client.search( # type: ignore
query_text,
user_id="alice",
limit=5,
)
print(f"mem0 search results:: {results}")
上面代码的输出如下:
mem0 search results:: {'results': [{'id': 'b77eee85-0246-4819-8f06-3c6da2e8e0ed', 'memory': 'Likes the color blue', 'hash': 'e5db483c46c111dbe776a0c23d898b48', 'metadata': None, 'score': 99409.875, 'created_at': '2026-04-02T23:45:16.512058-07:00', 'updated_at': None, 'user_id': 'alice'}]}
Context
- 想使用openviking实现一个类似mem0的功能
- 看了所有的openviking的文档,也尝试了很多openviking的用法,没有办法达到mem0 的输出效果相同。之前的尝试:[Question]: 关于client.session.search()执行的问题 #1195
谢谢你们
Code Example (Optional)
Related Area
None
Before Asking
- I have checked the documentation
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
questionFurther information is requestedFurther information is requested
Type
Projects
Status
Backlog