feat:单个agent配置各自的apiurl、apimodel、apikey

This commit is contained in:
liailing1026
2025-12-18 09:43:15 +08:00
parent 5ef86c6fa9
commit b42ab5aedd
7 changed files with 145 additions and 911 deletions

View File

@@ -19,7 +19,9 @@ onMounted(async () => {
const res = await readConfig<Agent[]>('agent.json')
agentsStore.setAgents(res)
}
await api.setAgents(agentsStore.agents.map(item => pick(item, ['Name', 'Profile'])))
await api.setAgents(
agentsStore.agents.map(item => pick(item, ['Name', 'Profile', 'apiUrl', 'apiKey', 'apiModel']))
)
})
// 上传agent文件
@@ -118,8 +120,6 @@ const readFileContent = (file: File) => {
return true
})
console.log('🔄 开始处理智能体数据...')
// 修改发送到后端的数据
const processedAgents = validAgents.map(agent => ({
Name: agent.Name,
@@ -131,35 +131,9 @@ const readFileContent = (file: File) => {
apiModel: agent.apiModel
}))
console.log(
'📤 发送到后端的智能体数据:',
processedAgents.map(a => ({
Name: a.Name,
apiUrl: a.apiUrl,
apiKey: a.apiKey ? '***' + a.apiKey.slice(-4) : '未设置',
apiModel: a.apiModel
}))
)
// 调用API
api
.setAgents(processedAgents)
.then(response => {
console.log('✅ 后端API调用成功响应:', response)
ElMessage.success('智能体上传成功')
})
.catch(error => {
console.error('❌ 后端API调用失败:', error)
ElMessage.error('智能体上传失败')
})
// 更新store
console.log('💾 更新智能体store...')
agentsStore.setAgents(processedAgents)
console.log('✅ 智能体store更新完成')
// 调用API
console.log('🌐 开始调用后端API...')
api
.setAgents(processedAgents)
.then(() => {