创建智能体

This commit is contained in:
2026-08-05 17:22:00 +08:00
parent fb421cd021
commit 2fff814c79
3 changed files with 175 additions and 73 deletions

View File

@@ -1759,6 +1759,53 @@ export const getAgentList = (token) => {
} else {
reject(`获取智能体列表失败:${res.statusCode}`)
}
},
fail: (err) => {
const msg = err.errMsg || '网络错误';
reject(msg);
}
})
})
}
// 创建智能体会话
export const addConversationAgent = (token, agent_id) => {
return new Promise((resolve, reject) => {
uni.request({
url: `${BASE_URL}/cloud_api/phone/conversation/agent/add`,
method: "POST",
header: {
"Content-Type": "application/json"
},
data: {
"access_token": token,
"agent_id": agent_id
},
success: (res) => {
if (res.statusCode === 200) {
const respond = res.data
// 返回格式: { success: true, title: "...", conversation_id: "...", workspace_id: "..." }
if (respond?.success && respond?.conversation_id) {
// 保存 workspace_id 到本地存储
if (respond.workspace_id) {
uni.setStorageSync('workspace_id', respond.workspace_id)
}
resolve({
conversation_id: respond.conversation_id,
workspace_id: respond.workspace_id,
title: respond.title || ''
})
} else {
const msg = respond?.error || '创建智能体会话出错啦'
reject(msg)
}
} else {
reject(`创建智能体会话失败:${res.statusCode}`)
}
},
fail: (err) => {
const msg = err.errMsg || '网络错误'
reject(msg)
}
})
})