35 lines
1.1 KiB
Python
35 lines
1.1 KiB
Python
"""客服 Agent 记忆上下文组装。"""
|
|||
|
|
|
||
|
|
from __future__ import annotations
|
||
|
|
|
||
|
|
from service.memory.schemas import CustomerMemoryContext, MemoryUnitDTO, ShortTermMessage
|
||
|
|
|
||
|
|
|
||
|
|
def build_customer_memory_context(
|
||
|
|
*,
|
||
|
|
customer_id: int,
|
||
|
|
session_id: str,
|
||
|
|
short_term_messages: list[ShortTermMessage],
|
||
|
|
customer_profile: dict | None,
|
||
|
|
work_orders: list[dict],
|
||
|
|
long_term_memories: list[MemoryUnitDTO],
|
||
|
|
customer_relations: list[dict] | None = None,
|
||
|
|
customer_products: list[dict] | None = None,
|
||
|
|
warnings: list[str] | None = None,
|
||
|
|
) -> CustomerMemoryContext:
|
||
|
|
"""构造稳定的客服记忆上下文结构。"""
|
||
|
|
return CustomerMemoryContext(
|
||
|
|
customer_id=customer_id,
|
||
|
|
session_id=session_id,
|
||
|
|
short_term_messages=short_term_messages,
|
||
|
|
customer_profile=customer_profile,
|
||
|
|
work_orders=work_orders,
|
||
|
|
long_term_memories=long_term_memories,
|
||
|
|
customer_relations=customer_relations or [],
|
||
|
|
customer_products=customer_products or [],
|
||
|
|
warnings=warnings or [],
|
||
|
|
)
|
||
|
|
|
||
|
|
|
||
|
|
__all__ = ["build_customer_memory_context"]
|