feat(agent): 增强 Agent 配置,新增结构化字段与聊天功能支持
This commit is contained in:
1 parent
ac4262cd75
commit
c8ce77199e
183 files changed
+11690
-2300
No files matched your search
@@ -0,0 +1,53 @@
|
||||
"""
|
||||
backend/app/services/shipping_notice/context_adapter.py
|
||||
|
||||
用途:发货通知 Agent 的 Context Adapter,构建 agent_runtime_context Dify inputs。
|
||||
依赖:shipping_notice.dify_inputs.build_dify_chat_inputs、agent_runtime_context.registry。
|
||||
逻辑:agent_code=shipping_notice 时由 build_chat_dify_inputs 分发至本模块;adapter_hints.shipping_notice 透传 task/batch。
|
||||
"""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from typing import Any
|
||||
|
||||
from app.services.agent_runtime_context.registry import register_context_adapter
|
||||
from app.services.shipping_notice.dify_inputs import build_dify_chat_inputs
|
||||
|
||||
|
||||
@register_context_adapter('shipping_notice')
|
||||
def build_shipping_notice_context_adapter(
|
||||
*,
|
||||
agent,
|
||||
session_id: str,
|
||||
adapter_hints: dict[str, Any] | None = None,
|
||||
request_id: str | None = None,
|
||||
trigger_source: str | None = 'frontend_chat',
|
||||
locale: str | None = None,
|
||||
**kwargs: Any,
|
||||
) -> dict[str, Any]:
|
||||
"""
|
||||
构建发货通知 Dify Start inputs。
|
||||
|
||||
核心逻辑:从 adapter_hints.shipping_notice 读取 task_id/batch_no,委托 dify_inputs 组装 runtime_context。
|
||||
|
||||
Args:
|
||||
agent: 当前对话 Agent(保留签名一致性;发货上下文主要依赖 session_id)。
|
||||
session_id: HXOPS 会话 ID。
|
||||
adapter_hints: 含 shipping_notice 子 dict 时可携带 task_id、batch_no。
|
||||
request_id: 请求追踪 ID。
|
||||
trigger_source: 触发来源。
|
||||
locale: 用户语言。
|
||||
|
||||
Returns:
|
||||
含 agent_runtime_context 的 Dify inputs;session_id 为空时返回空 dict。
|
||||
"""
|
||||
shipping_hints = adapter_hints.get('shipping_notice') if isinstance(adapter_hints, dict) else {}
|
||||
shipping_hints = shipping_hints if isinstance(shipping_hints, dict) else {}
|
||||
return build_dify_chat_inputs(
|
||||
session_id,
|
||||
task_id=shipping_hints.get('task_id'),
|
||||
batch_no=shipping_hints.get('batch_no'),
|
||||
trigger_source=trigger_source,
|
||||
request_id=request_id,
|
||||
locale=locale,
|
||||
)
|
||||
Reference in new issue
Block a user