mirror of
https://gitee.com/qqtt-ah/ecom-dmb.git
synced 2026-11-24 11:09:19 +08:00
feat: 拼多多发布页接入场景智能体与表单改写工具
This commit is contained in:
@@ -25,6 +25,9 @@ class SessionService:
|
||||
title: str | None = None,
|
||||
llm_provider_id: int | None = None,
|
||||
llm_model: str | None = None,
|
||||
*,
|
||||
scene: str | None = None,
|
||||
scene_ref: str | None = None,
|
||||
) -> Session:
|
||||
now = datetime.utcnow()
|
||||
model = (llm_model or "").strip() or None
|
||||
@@ -40,12 +43,16 @@ class SessionService:
|
||||
provider_id = rt.provider_id if rt.provider_id is not None else provider_id
|
||||
except Exception:
|
||||
pass
|
||||
scene_value = (scene or "general").strip() or "general"
|
||||
ref = (scene_ref or "").strip() or None
|
||||
session = Session(
|
||||
thread_id=str(uuid.uuid4()),
|
||||
company_id=actor.company_id,
|
||||
user_id=actor.user_id,
|
||||
title=(title or "新对话").strip() or "新对话",
|
||||
status=SessionStatus.ACTIVE,
|
||||
scene=scene_value,
|
||||
scene_ref=ref,
|
||||
llm_provider_id=provider_id,
|
||||
llm_model=model,
|
||||
created_at=now,
|
||||
@@ -53,8 +60,23 @@ class SessionService:
|
||||
)
|
||||
return await self._sessions.create(session)
|
||||
|
||||
async def list_mine(self, actor: Actor) -> list[Session]:
|
||||
return await self._sessions.list_active(actor.company_id, actor.user_id)
|
||||
async def list_mine(
|
||||
self, actor: Actor, *, scene: str | None = None
|
||||
) -> list[Session]:
|
||||
return await self._sessions.list_active(
|
||||
actor.company_id, actor.user_id, scene=scene
|
||||
)
|
||||
|
||||
async def find_by_scene_ref(
|
||||
self, actor: Actor, *, scene: str, scene_ref: str
|
||||
) -> Session | None:
|
||||
"""同一 scene_ref 复用已有活跃会话(一草稿一会话)。"""
|
||||
return await self._sessions.find_active_by_scene_ref(
|
||||
actor.company_id,
|
||||
actor.user_id,
|
||||
scene=scene,
|
||||
scene_ref=scene_ref,
|
||||
)
|
||||
|
||||
async def require_owned(self, actor: Actor, thread_id: str) -> Session:
|
||||
session = await self._sessions.get(actor.company_id, actor.user_id, thread_id)
|
||||
|
||||
Reference in New Issue
Block a user