Merge branch 'dev' into runny827
feat(training): 新增精益培训视频与周任务管理 # Conflicts: # backend/app/models/__init__.py
This commit is contained in:
1 parent
85d27e9ffa
commit
91b7233872
812 files changed
+73763
-18908
No files matched your search
@@ -12,4 +12,5 @@ from __future__ import annotations
|
||||
RUNTIME_HANDLER_BINDINGS: dict[str, str] = {
|
||||
'shipping_notice': 'shipping_notice',
|
||||
'file_check': 'file_check',
|
||||
'in_transit_transfer': 'in_transit_transfer',
|
||||
}
|
||||
@@ -129,3 +129,35 @@ agent_types:
|
||||
file_upload: true
|
||||
human_confirm: false
|
||||
handler_config_schema: {}
|
||||
in_transit_transfer:
|
||||
label: 在途仓自动调拨
|
||||
conversation_mode_default: task_chat
|
||||
runtime_provider_default: hybrid
|
||||
models:
|
||||
- TransferRun
|
||||
- TransferPrecheck
|
||||
- TransferInvoiceItem
|
||||
required_fields: []
|
||||
default_capabilities:
|
||||
task_progress: true
|
||||
human_confirm: true
|
||||
forced_capabilities:
|
||||
human_confirm: true
|
||||
progress_contract:
|
||||
enabled: true
|
||||
data_source:
|
||||
type: domain_state
|
||||
domain: in_transit_transfer
|
||||
update:
|
||||
transport: sse
|
||||
event: transfer_ui_state
|
||||
binding:
|
||||
type: conversation_context
|
||||
keys:
|
||||
- run_no
|
||||
- precheck_id
|
||||
requires_schedule_task: false
|
||||
presentation:
|
||||
layout: card
|
||||
visualization: stepper
|
||||
handler_config_schema: {}
|
||||
@@ -30,10 +30,12 @@ def load_handlers() -> None:
|
||||
import importlib
|
||||
|
||||
import app.services.agent_registry.handlers.file_check as file_check_mod
|
||||
import app.services.agent_registry.handlers.in_transit_transfer as in_transit_transfer_mod
|
||||
import app.services.agent_registry.handlers.shipping_notice as shipping_mod
|
||||
|
||||
importlib.reload(file_check_mod)
|
||||
importlib.reload(shipping_mod)
|
||||
importlib.reload(in_transit_transfer_mod)
|
||||
|
||||
logger.info('Agent handlers loaded: %s', sorted(HANDLER_REGISTRY.keys()))
|
||||
_handlers_loaded = True
|
||||
|
||||
@@ -0,0 +1,34 @@
|
||||
"""
|
||||
用途:在途仓自动调拨 Hybrid Handler。
|
||||
|
||||
依赖:agent_registry.handlers.base/registry。
|
||||
逻辑:在途调拨的进度与结果卡由 Chat Action(transfer.precheck / transfer.execute)
|
||||
输出结构化 message.completed 卡片,并经 Run API 恢复;本 Handler 负责 hybrid
|
||||
运行时的上下文钩子与领域 UI State 扩展位(transfer_ui_state),暂不注入
|
||||
Dify Chatflow 生命周期。
|
||||
"""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from typing import Any
|
||||
|
||||
from app.services.agent_registry.handlers.base import AgentHandler, ChatStreamContext
|
||||
from app.services.agent_registry.handlers.registry import register_handler
|
||||
|
||||
|
||||
@register_handler('in_transit_transfer')
|
||||
class InTransitTransferHandler(AgentHandler):
|
||||
"""
|
||||
在途仓自动调拨业务 Handler。
|
||||
|
||||
核心逻辑:预检/执行/结果卡不进入普通 Dify 生命周期(后台 Run 持久化 + 卡片消息
|
||||
+ Run API 恢复);prepare_stream / build_ui_state_event 预留领域扩展位。
|
||||
"""
|
||||
|
||||
def prepare_stream(self, ctx: ChatStreamContext) -> ChatStreamContext:
|
||||
"""Dify 流开始前:校验领域上下文(预留 run_no/precheck_id 锚点)。"""
|
||||
return ctx
|
||||
|
||||
def build_ui_state_event(self, ctx: ChatStreamContext) -> dict[str, Any] | None:
|
||||
"""构造 transfer_ui_state SSE 事件(预留;进度由卡片消息 + Run API 提供)。"""
|
||||
return None
|
||||
@@ -89,10 +89,10 @@ class ShippingNoticeHandler(AgentHandler):
|
||||
if str(event.get('event') or '') != 'shipping_ui_state':
|
||||
return None
|
||||
ui_state = event.get('ui_state') if isinstance(event.get('ui_state'), dict) else {}
|
||||
checkpoint = ui_state.get('checkpoint')
|
||||
return json.dumps({
|
||||
'task_no': event.get('task_no'),
|
||||
'checkpoint': checkpoint,
|
||||
'position': ui_state.get('position'),
|
||||
'user_mode': ui_state.get('user_mode'),
|
||||
'updated_at': ui_state.get('updated_at'),
|
||||
}, ensure_ascii=False, sort_keys=True)
|
||||
|
||||
|
||||
Reference in new issue
Block a user