1.排程管理新增检核规则提示词维护,用于传入Dify中作为检核规则
2.聊天界面内容不可复制问题修复
This commit is contained in:
1 parent
452f6ebc6d
commit
ff2d02051f
17 files changed
+355
-20
No files matched your search
@@ -0,0 +1,40 @@
|
||||
from __future__ import annotations
|
||||
|
||||
from datetime import datetime
|
||||
from typing import Any
|
||||
|
||||
from app import db
|
||||
from app.models import Agent, ScheduleRun, ScheduleTask
|
||||
from app.services.schedule.sql_config import get_schedule_sql_config_by_task_id
|
||||
|
||||
|
||||
def build_dify_execution_snapshot(task: ScheduleTask) -> dict[str, Any]:
|
||||
"""Capture Dify agent + system prompt used at execution time for audit."""
|
||||
captured_at = datetime.utcnow().isoformat() + "Z"
|
||||
if not task.dify_agent_id:
|
||||
return {
|
||||
"dify_enabled": False,
|
||||
"dify_agent_id": None,
|
||||
"dify_agent_name": None,
|
||||
"dify_app_id": None,
|
||||
"dify_system_prompt": "",
|
||||
"captured_at": captured_at,
|
||||
}
|
||||
|
||||
cfg = get_schedule_sql_config_by_task_id(task.id)
|
||||
prompt = str(cfg.dify_system_prompt if cfg else "").strip()
|
||||
agent = db.session.get(Agent, task.dify_agent_id)
|
||||
return {
|
||||
"dify_enabled": True,
|
||||
"dify_agent_id": task.dify_agent_id,
|
||||
"dify_agent_name": getattr(agent, "name", None) if agent else None,
|
||||
"dify_app_id": getattr(agent, "dify_app_id", None) if agent else None,
|
||||
"dify_system_prompt": prompt,
|
||||
"captured_at": captured_at,
|
||||
}
|
||||
|
||||
|
||||
def capture_dify_execution_snapshot(run: ScheduleRun, task: ScheduleTask) -> dict[str, Any]:
|
||||
snapshot = build_dify_execution_snapshot(task)
|
||||
run.dify_execution_snapshot = snapshot
|
||||
return snapshot
|
||||
Reference in new issue
Block a user