mirror of
https://github.com/xinnan-tech/xiaozhi-esp32-server.git
synced 2026-11-29 05:09:46 +01:00
合并代码
This commit is contained in:
commit
150436d14f
3 changed files with 6 additions and 6 deletions
|
|
@ -102,8 +102,7 @@ class ConnectionHandler:
|
||||||
await self.auth.authenticate(self.headers)
|
await self.auth.authenticate(self.headers)
|
||||||
|
|
||||||
device_id = self.headers.get("device-id", None)
|
device_id = self.headers.get("device-id", None)
|
||||||
self.memory.set_role_id(device_id)
|
self.memory.init_memory(device_id, self.llm)
|
||||||
self.memory.set_llm(self.llm)
|
|
||||||
self.intent.set_llm(self.llm)
|
self.intent.set_llm(self.llm)
|
||||||
|
|
||||||
# Load private configuration if device_id is provided
|
# Load private configuration if device_id is provided
|
||||||
|
|
|
||||||
|
|
@ -20,9 +20,6 @@ class MemoryProviderBase(ABC):
|
||||||
"""Query memories for specific role based on similarity"""
|
"""Query memories for specific role based on similarity"""
|
||||||
return "please implement query method"
|
return "please implement query method"
|
||||||
|
|
||||||
def set_role_id(self, role_id: str):
|
def init_memory(self, role_id, llm):
|
||||||
self.role_id = role_id
|
self.role_id = role_id
|
||||||
|
|
||||||
def set_llm(self, llm):
|
|
||||||
self.llm = llm
|
self.llm = llm
|
||||||
logger.bind(tag=TAG).debug("Set LLM for memory provider")
|
|
||||||
|
|
@ -95,6 +95,10 @@ class MemoryProvider(MemoryProviderBase):
|
||||||
self.memory_path = get_project_dir() + 'data/.memory.yaml'
|
self.memory_path = get_project_dir() + 'data/.memory.yaml'
|
||||||
self.load_memory()
|
self.load_memory()
|
||||||
|
|
||||||
|
def init_memory(self, role_id, llm):
|
||||||
|
super().init_memory(role_id, llm)
|
||||||
|
self.load_memory()
|
||||||
|
|
||||||
def load_memory(self):
|
def load_memory(self):
|
||||||
all_memory = {}
|
all_memory = {}
|
||||||
if os.path.exists(self.memory_path):
|
if os.path.exists(self.memory_path):
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue