mirror of
https://gitee.com/qqtt-ah/ecom-dmb.git
synced 2026-11-24 19:09:19 +08:00
feat: 拼多多发布页接入场景智能体与表单改写工具
This commit is contained in:
@@ -58,6 +58,10 @@ class Session:
|
||||
title: str = "新对话"
|
||||
status: SessionStatus = SessionStatus.ACTIVE
|
||||
summary: str | None = None
|
||||
# general=经营助手;ecom_goods_publish=拼多多商品发布编辑
|
||||
scene: str = "general"
|
||||
# 场景业务键,如发布草稿 draftId
|
||||
scene_ref: str | None = None
|
||||
# 会话选用的提供商 + 模型(同名 model 靠 provider 消歧)
|
||||
llm_provider_id: int | None = None
|
||||
llm_model: str | None = None
|
||||
@@ -66,6 +70,10 @@ class Session:
|
||||
last_message_at: datetime | None = None
|
||||
|
||||
|
||||
SCENE_GENERAL = "general"
|
||||
SCENE_ECOM_GOODS_PUBLISH = "ecom_goods_publish"
|
||||
|
||||
|
||||
@dataclass
|
||||
class ChatMessage:
|
||||
company_id: int
|
||||
@@ -114,13 +122,15 @@ class LlmRuntimeConfig:
|
||||
|
||||
@dataclass(frozen=True)
|
||||
class StreamEvent:
|
||||
"""流式片段:正文 token 或工具状态(工具状态不进落库正文)。"""
|
||||
"""流式片段:正文 token、服务端工具状态、或需前端执行的 client tool。"""
|
||||
|
||||
kind: str # token | tool
|
||||
kind: str # token | tool | client_tool | pending_client_tools
|
||||
text: str | None = None
|
||||
phase: str | None = None # start | end
|
||||
name: str | None = None
|
||||
label: str | None = None
|
||||
tool_call_id: str | None = None
|
||||
args: dict | None = None
|
||||
|
||||
@staticmethod
|
||||
def token(text: str) -> StreamEvent:
|
||||
@@ -129,3 +139,23 @@ class StreamEvent:
|
||||
@staticmethod
|
||||
def tool(*, phase: str, name: str, label: str) -> StreamEvent:
|
||||
return StreamEvent(kind="tool", phase=phase, name=name, label=label)
|
||||
|
||||
@staticmethod
|
||||
def client_tool(
|
||||
*,
|
||||
tool_call_id: str,
|
||||
name: str,
|
||||
args: dict | None,
|
||||
label: str,
|
||||
) -> StreamEvent:
|
||||
return StreamEvent(
|
||||
kind="client_tool",
|
||||
tool_call_id=tool_call_id,
|
||||
name=name,
|
||||
args=args or {},
|
||||
label=label,
|
||||
)
|
||||
|
||||
@staticmethod
|
||||
def pending_client_tools() -> StreamEvent:
|
||||
return StreamEvent(kind="pending_client_tools")
|
||||
|
||||
@@ -16,7 +16,24 @@ class SessionRepository(ABC):
|
||||
async def get(self, company_id: int, user_id: str, thread_id: str) -> Session | None: ...
|
||||
|
||||
@abstractmethod
|
||||
async def list_active(self, company_id: int, user_id: str, limit: int = 50) -> list[Session]: ...
|
||||
async def list_active(
|
||||
self,
|
||||
company_id: int,
|
||||
user_id: str,
|
||||
limit: int = 50,
|
||||
*,
|
||||
scene: str | None = None,
|
||||
) -> list[Session]: ...
|
||||
|
||||
@abstractmethod
|
||||
async def find_active_by_scene_ref(
|
||||
self,
|
||||
company_id: int,
|
||||
user_id: str,
|
||||
*,
|
||||
scene: str,
|
||||
scene_ref: str,
|
||||
) -> Session | None: ...
|
||||
|
||||
@abstractmethod
|
||||
async def update(self, session: Session) -> Session: ...
|
||||
|
||||
Reference in New Issue
Block a user