mirror of
https://github.com/xinnan-tech/xiaozhi-esp32-server.git
synced 2026-11-28 04:59:52 +01:00
feat: 修复deviceid to user id
This commit is contained in:
parent
91c2ed709f
commit
d18f2b5113
4 changed files with 8 additions and 1 deletions
|
|
@ -98,6 +98,7 @@ async def resolve_agent_by_wake(
|
||||||
data=DeviceAgentResolveResponse(
|
data=DeviceAgentResolveResponse(
|
||||||
device_id=resolved.device_id,
|
device_id=resolved.device_id,
|
||||||
agent_id=resolved.agent_id,
|
agent_id=resolved.agent_id,
|
||||||
|
owner_id=resolved.owner_id, # Device owner's user_id for memory storage
|
||||||
is_default=resolved.is_default,
|
is_default=resolved.is_default,
|
||||||
match_type=resolved.match_type,
|
match_type=resolved.match_type,
|
||||||
agent_config=agent_cfg,
|
agent_config=agent_cfg,
|
||||||
|
|
|
||||||
|
|
@ -65,6 +65,7 @@ class DeviceAgentResolveResponse(BaseModel):
|
||||||
"""Resolve agent for device by wake word or default"""
|
"""Resolve agent for device by wake word or default"""
|
||||||
device_id: str
|
device_id: str
|
||||||
agent_id: str
|
agent_id: str
|
||||||
|
owner_id: Optional[str] = None # Device owner's user_id for memory storage
|
||||||
is_default: bool
|
is_default: bool
|
||||||
match_type: Literal["wake_word", "default"]
|
match_type: Literal["wake_word", "default"]
|
||||||
agent_config: AgentConfigResponse
|
agent_config: AgentConfigResponse
|
||||||
|
|
|
||||||
|
|
@ -267,6 +267,7 @@ class DeviceService:
|
||||||
return DeviceAgentResolveResponse(
|
return DeviceAgentResolveResponse(
|
||||||
device_id=device_id,
|
device_id=device_id,
|
||||||
agent_id=matched_agent.agent_id,
|
agent_id=matched_agent.agent_id,
|
||||||
|
owner_id=device.owner_id, # Device owner's user_id for memory storage
|
||||||
is_default=matched_binding.is_default,
|
is_default=matched_binding.is_default,
|
||||||
match_type=match_type,
|
match_type=match_type,
|
||||||
agent_config=agent_config,
|
agent_config=agent_config,
|
||||||
|
|
|
||||||
|
|
@ -81,6 +81,7 @@ class ConnectionHandler:
|
||||||
self.websocket = None
|
self.websocket = None
|
||||||
self.headers = None
|
self.headers = None
|
||||||
self.device_id = None
|
self.device_id = None
|
||||||
|
self.owner_id = None # Device owner's user_id for memory storage
|
||||||
self.client_ip = None
|
self.client_ip = None
|
||||||
self.prompt = None
|
self.prompt = None
|
||||||
self.welcome_msg = None
|
self.welcome_msg = None
|
||||||
|
|
@ -790,8 +791,10 @@ class ConnectionHandler:
|
||||||
if self.memory is None:
|
if self.memory is None:
|
||||||
return
|
return
|
||||||
"""初始化记忆模块"""
|
"""初始化记忆模块"""
|
||||||
|
# Use owner_id (real user_id) for memory storage, fallback to device_id if not available
|
||||||
|
memory_user_id = self.owner_id if self.owner_id else self.device_id
|
||||||
self.memory.init_memory(
|
self.memory.init_memory(
|
||||||
role_id=self.device_id,
|
role_id=memory_user_id,
|
||||||
llm=self.llm,
|
llm=self.llm,
|
||||||
agent_id=self.agent_id,
|
agent_id=self.agent_id,
|
||||||
summary_memory=self.config.get("summaryMemory", None),
|
summary_memory=self.config.get("summaryMemory", None),
|
||||||
|
|
@ -966,6 +969,7 @@ class ConnectionHandler:
|
||||||
self.need_bind = True
|
self.need_bind = True
|
||||||
return False
|
return False
|
||||||
self.agent_id = resolved.get("agent_id")
|
self.agent_id = resolved.get("agent_id")
|
||||||
|
self.owner_id = resolved.get("owner_id") # Device owner's user_id
|
||||||
private_config = resolved.get("agent_config")
|
private_config = resolved.get("agent_config")
|
||||||
|
|
||||||
if private_config is None:
|
if private_config is None:
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue