mirror of
https://gitee.com/qqtt-ah/ecom-dmb.git
synced 2026-11-24 23:09:19 +08:00
feat: 长期记忆改为摘要检索并由模型按需载入
This commit is contained in:
@@ -1,15 +1,15 @@
|
||||
"""对话用例:落库 + 记忆注入 + MCP tools + 流式生成。"""
|
||||
"""对话用例:落库 + 记忆工具按需载入 + MCP + 流式生成。"""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from datetime import datetime
|
||||
from typing import AsyncIterator
|
||||
|
||||
from agent.runtime import load_tools_for_turn
|
||||
from application.llm_settings_service import LlmRuntimeService
|
||||
from application.memory_service import MemoryService
|
||||
from application.session_service import SessionService
|
||||
from config.settings import Settings
|
||||
from agent.runtime import load_tools_for_turn
|
||||
from domain.models import Actor, ChatMessage, MessageRole
|
||||
from domain.ports import ChatStreamer, MessageRepository, SessionRepository
|
||||
|
||||
@@ -51,14 +51,14 @@ class ChatService:
|
||||
|
||||
session = await self._sessions.require_owned(actor, thread_id)
|
||||
llm = await self._llm_runtime.resolve_runtime(actor.company_id)
|
||||
await self._memory.maybe_capture_from_user(
|
||||
just_saved = await self._memory.maybe_capture_from_user(
|
||||
actor, thread_id=thread_id, text=text
|
||||
)
|
||||
memory_lines = await self._memory.lines_for_prompt(actor)
|
||||
memory_count = await self._memory.count_active(actor)
|
||||
tools = await load_tools_for_turn(
|
||||
self._settings,
|
||||
company_id=actor.company_id,
|
||||
user_id=actor.user_id,
|
||||
actor=actor,
|
||||
memory=self._memory,
|
||||
)
|
||||
|
||||
history = await self._messages.list_recent(
|
||||
@@ -89,8 +89,9 @@ class ChatService:
|
||||
llm=llm,
|
||||
history=history,
|
||||
user_text=text,
|
||||
memory_lines=memory_lines,
|
||||
tools=tools or None,
|
||||
memory_count=memory_count,
|
||||
memory_just_saved=just_saved,
|
||||
):
|
||||
parts.append(chunk)
|
||||
yield chunk
|
||||
|
||||
Reference in New Issue
Block a user