in bigtop-manager-ui/src/store/ai-assistant/index.ts [85:149]
await getThread(data.threadId as ThreadId, quickCreate)
getThreadsFromAuthPlatform()
}
} catch (error) {
console.log('error :>> ', error)
}
}
const updateChatThread = async (thread: ChatThread, newName: string) => {
try {
const threadId = thread.threadId as ThreadId
await ai.updateThread(threadId, { name: newName })
return true
} catch (error) {
return false
}
}
const deleteChatThread = async (thread: ChatThread) => {
try {
const threadId = thread.threadId as ThreadId
await ai.deleteThread(threadId)
return true
} catch (error) {
return false
}
}
const getThread = async (threadId: ThreadId, quickCreate = false) => {
try {
const data = await ai.getThread(threadId)
currThread.value = data
!quickCreate && (await getThreadRecords())
} catch (error) {
console.log('error :>> ', error)
}
}
const getThreadsFromAuthPlatform = async () => {
try {
const data = await ai.getThreadsFromAuthPlatform()
threads.value = data
} catch (error) {
console.log('error :>> ', error)
}
}
const getThreadRecords = async () => {
try {
loadingChatRecords.value = true
const { threadId } = currThread.value
const data = await ai.getThreadRecords(threadId as ThreadId)
chatRecords.value = data
} catch (error) {
console.log('error :>> ', error)
} finally {
loadingChatRecords.value = false
}
}
const talkWithChatbot = async (message: string) => {
try {
const { threadId } = currThread.value
isSending.value = true
if (threadId) {