使用mem0ai api实现记忆功能

This commit is contained in:
玄凤科技
2025-03-03 15:00:04 +08:00
parent effd79b465
commit f2e68060de
7 changed files with 151 additions and 7 deletions
+23
View File
@@ -0,0 +1,23 @@
from abc import ABC, abstractmethod
from config.logger import setup_logging
TAG = __name__
logger = setup_logging()
class MemoryProviderBase(ABC):
def __init__(self, config):
self.config = config
self.role_id = None
@abstractmethod
async def save_memory(self, msgs):
"""Save a new memory for specific role and return memory ID"""
print("this is base func", msgs)
@abstractmethod
async def query_memory(self, query: str) -> str:
"""Query memories for specific role based on similarity"""
return "please implement query method"
def set_role_id(self, role_id: str):
self.role_id = role_id