修复智能体市场点击安装无效的问题
This commit is contained in:
parent
fb2363be65
commit
cad79887f5
@ -268,23 +268,26 @@ async function performPublish() {
|
||||
throw new Error(t('Agent flow data is required'))
|
||||
}
|
||||
|
||||
// 解析 agent_flow(如果是字符串)
|
||||
// agent_flow 是 JSON 字段类型,从数据库获取时可能是字符串或对象
|
||||
// 统一处理:如果是字符串则解析为对象,如果是对象则直接使用
|
||||
let flowData = agentFlow
|
||||
if (typeof agentFlow === 'string') {
|
||||
try {
|
||||
flowData = JSON.parse(agentFlow)
|
||||
} catch (e) {
|
||||
// 如果解析失败,保持原样
|
||||
throw new Error(t('Invalid agent flow data format'))
|
||||
}
|
||||
} else if (typeof agentFlow !== 'object' || agentFlow === null) {
|
||||
throw new Error(t('Agent flow data must be a valid JSON object'))
|
||||
}
|
||||
|
||||
// 准备发布数据
|
||||
// 准备发布数据(flowData 现在是对象,后端会处理 JSON 序列化)
|
||||
const publishData = {
|
||||
agent_name: agentName,
|
||||
title: props.record?.title || agentName,
|
||||
subtitle: props.record?.subtitle || '',
|
||||
description: props.record?.description || '',
|
||||
agent_flow: flowData
|
||||
agent_flow: flowData // 对象格式,axios 会自动序列化为 JSON
|
||||
}
|
||||
|
||||
const response = await axios.post('/jingrow/agent/publish', publishData, {
|
||||
|
||||
@ -856,12 +856,9 @@ async def install_agent(payload: Dict[str, Any]):
|
||||
value=agent_name,
|
||||
)
|
||||
|
||||
# 准备数据
|
||||
agent_data = {
|
||||
"agent_name": agent_name,
|
||||
"agent_flow": json.dumps(agent_flow, ensure_ascii=False) if isinstance(agent_flow, dict) else agent_flow,
|
||||
"status": "Active",
|
||||
"enabled": 1,
|
||||
"trigger_mode": "Manual Trigger"
|
||||
}
|
||||
|
||||
@ -938,10 +935,20 @@ async def publish_agent_to_marketplace(payload: Dict[str, Any]):
|
||||
headers['Content-Type'] = 'application/json'
|
||||
|
||||
# 准备 agent_data
|
||||
# agent_flow 是 JSON 字段:前端发送的可能是对象(dict)或字符串
|
||||
# 需要统一转换为字符串格式发送到云端
|
||||
agent_flow_str = agent_flow
|
||||
if isinstance(agent_flow, dict):
|
||||
# 如果是对象,转为 JSON 字符串
|
||||
agent_flow_str = json.dumps(agent_flow, ensure_ascii=False)
|
||||
elif not isinstance(agent_flow, str):
|
||||
# 如果不是字符串也不是对象,尝试转为字符串
|
||||
agent_flow_str = json.dumps(agent_flow, ensure_ascii=False)
|
||||
|
||||
agent_data = {
|
||||
"agent_name": agent_name,
|
||||
"title": title,
|
||||
"agent_flow": agent_flow if isinstance(agent_flow, str) else json.dumps(agent_flow, ensure_ascii=False),
|
||||
"agent_flow": agent_flow_str,
|
||||
"description": description,
|
||||
"subtitle": subtitle or ""
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user