feat: 拼多多发布页接入场景智能体与表单改写工具

This commit is contained in:
2026-09-20 23:18:28 +08:00
parent d28b4d45c3
commit a140cff81a
31 changed files with 1660 additions and 44 deletions
+26 -5
View File
@@ -45,13 +45,19 @@ class ChatService:
)
async def stream_chat(
self, actor: Actor, thread_id: str, content: str
self,
actor: Actor,
thread_id: str,
content: str,
*,
form_snapshot: dict | None = None,
) -> AsyncIterator[StreamEvent]:
text = (content or "").strip()
if not text:
raise ValueError("消息不能为空")
session = await self._sessions.require_owned(actor, thread_id)
scene = session.scene or "general"
llm = await self._llm_runtime.resolve_runtime(
actor.company_id,
provider_id=session.llm_provider_id,
@@ -67,18 +73,33 @@ class ChatService:
changed = True
if changed:
await self._session_repo.update(session)
just_saved = await self._memory.maybe_capture_from_user(
actor, thread_id=thread_id, text=text
)
memory_count = await self._memory.count_active(actor)
just_saved = None
memory_count = 0
if scene == "general":
just_saved = await self._memory.maybe_capture_from_user(
actor, thread_id=thread_id, text=text
)
memory_count = await self._memory.count_active(actor)
system_prompt = build_system_prompt(
memory_count=memory_count,
memory_just_saved=just_saved,
scene=scene,
)
client_tools = None
if scene == "ecom_goods_publish":
from agent.tools.publish_ui import build_publish_client_tools
client_tools = build_publish_client_tools(form_snapshot=form_snapshot)
tools = await load_tools_for_turn(
self._settings,
actor=actor,
memory=self._memory,
scene=scene,
client_tools=client_tools,
)
raw_history = await self._messages.list_recent(