feat:单个agent配置各自的apiurl、apimodel、apikey
This commit is contained in:
@@ -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(() => {
|
||||
|
||||
Reference in New Issue
Block a user