创建智能体
This commit is contained in:
@@ -367,7 +367,8 @@
|
||||
getUserInfo,
|
||||
getUserAvatar,
|
||||
conversationMessageDownload,
|
||||
getAgentList
|
||||
getAgentList,
|
||||
addConversationAgent
|
||||
} from '@/utils/cloud-api.js'
|
||||
import {
|
||||
getToken,
|
||||
@@ -773,32 +774,26 @@ import { openFile as openFileNative, downloadAndOpen } from '@/utils/fileOpener.
|
||||
}
|
||||
|
||||
const handleAgentSelect = async (agent) => {
|
||||
console.log("点击了",agent.title);
|
||||
// try {
|
||||
// closeAgentModal()
|
||||
// const chars = '0123456789abcdef'
|
||||
// let name = ''
|
||||
// for (let i = 0; i < 24; i++) {
|
||||
// name += chars[Math.floor(Math.random() * chars.length)]
|
||||
// }
|
||||
// const workspaceId = await createWorkspace(userToken.value, name)
|
||||
// if (!workspaceId) {
|
||||
// uni.showToast({ title: '工作区创建失败', icon: 'none' })
|
||||
// return
|
||||
// }
|
||||
// const loginInfo = uni.getStorageSync('yxd_login_info')
|
||||
// const userName = loginInfo ? (loginInfo.username || '') : ''
|
||||
// const conversationId = await createConversation(userToken.value, workspaceId, agent.title, userName)
|
||||
// if (!conversationId) {
|
||||
// uni.showToast({ title: '智能体会话创建失败', icon: 'none' })
|
||||
// return
|
||||
// }
|
||||
// uni.showToast({ title: `已创建「${agent.title}」会话`, icon: 'success' })
|
||||
// takeUserConversations()
|
||||
// } catch (error) {
|
||||
// console.error('创建智能体会话失败:', error)
|
||||
// uni.showToast({ title: '创建失败,请重试', icon: 'none' })
|
||||
// }
|
||||
closeAgentModal()
|
||||
uni.showLoading({ title: '正在创建智能体...', mask: true })
|
||||
try {
|
||||
const result = await addConversationAgent(userToken.value, agent._id)
|
||||
if (!result || !result.conversation_id) {
|
||||
uni.hideLoading()
|
||||
uni.showToast({ title: '智能体会话创建失败', icon: 'none' })
|
||||
return
|
||||
}
|
||||
// 刷新会话列表
|
||||
await takeUserConversations()
|
||||
// 切换到新创建的会话
|
||||
currentSessionId.value = result.conversation_id
|
||||
uni.hideLoading()
|
||||
uni.showToast({ title: `已创建「${result.title || agent.title}」会话`, icon: 'success' })
|
||||
} catch (error) {
|
||||
uni.hideLoading()
|
||||
console.error('创建智能体会话失败:', error)
|
||||
uni.showToast({ title: typeof error === 'string' ? error : '创建失败,请重试', icon: 'none' })
|
||||
}
|
||||
}
|
||||
|
||||
// 侧边栏相关
|
||||
@@ -1720,8 +1715,7 @@ import { openFile as openFileNative, downloadAndOpen } from '@/utils/fileOpener.
|
||||
const rawMessages = await getConversationMessages(userToken.value, currentSessionId.value, pageSize, 0) || [];
|
||||
// API 返回的数据已被过滤,无法通过数量判断是否有更多,始终尝试加载更多
|
||||
allmessages.value = rawMessages
|
||||
console.log("获取到的所有消息:", JSON.stringify(allmessages.value) );
|
||||
// console.log("获取到的所有消息:", allmessages.value);
|
||||
// console.log("获取到的所有消息:", JSON.stringify(allmessages.value) );
|
||||
// currentMessages.value = allmessages.value.slice(-pageInfoNumber);
|
||||
// 数据获取后执行滚动
|
||||
scrollToBottom();
|
||||
|
||||
Reference in New Issue
Block a user