fix/no-assistant-available-fresh-install (#876)
This commit is contained in:
parent
efdc7762e5
commit
9e6fdf8c94
@ -7,7 +7,7 @@ import CommandSearch from '@/containers/Layout/TopBar/CommandSearch'
|
|||||||
import { MainViewState } from '@/constants/screens'
|
import { MainViewState } from '@/constants/screens'
|
||||||
|
|
||||||
import { useCreateNewThread } from '@/hooks/useCreateNewThread'
|
import { useCreateNewThread } from '@/hooks/useCreateNewThread'
|
||||||
import useGetAssistants from '@/hooks/useGetAssistants'
|
import useGetAssistants, { getAssistants } from '@/hooks/useGetAssistants'
|
||||||
import { useMainViewState } from '@/hooks/useMainViewState'
|
import { useMainViewState } from '@/hooks/useMainViewState'
|
||||||
|
|
||||||
import { showRightSideBarAtom } from '@/screens/Chat/Sidebar'
|
import { showRightSideBarAtom } from '@/screens/Chat/Sidebar'
|
||||||
@ -33,10 +33,18 @@ const TopBar = () => {
|
|||||||
|
|
||||||
const onCreateConversationClick = async () => {
|
const onCreateConversationClick = async () => {
|
||||||
if (assistants.length === 0) {
|
if (assistants.length === 0) {
|
||||||
alert('No assistant available')
|
await getAssistants().then((res) => {
|
||||||
return
|
if (res) {
|
||||||
|
if (res.length === 0) {
|
||||||
|
alert('No assistant available')
|
||||||
|
return
|
||||||
|
}
|
||||||
|
requestCreateNewThread(res[0])
|
||||||
|
}
|
||||||
|
})
|
||||||
|
} else {
|
||||||
|
requestCreateNewThread(assistants[0])
|
||||||
}
|
}
|
||||||
requestCreateNewThread(assistants[0])
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|||||||
@ -4,7 +4,7 @@ import { Assistant, ExtensionType, AssistantExtension } from '@janhq/core'
|
|||||||
|
|
||||||
import { extensionManager } from '@/extension/ExtensionManager'
|
import { extensionManager } from '@/extension/ExtensionManager'
|
||||||
|
|
||||||
const getAssistants = async (): Promise<Assistant[]> => {
|
export const getAssistants = async (): Promise<Assistant[]> => {
|
||||||
return (
|
return (
|
||||||
extensionManager
|
extensionManager
|
||||||
.get<AssistantExtension>(ExtensionType.Assistant)
|
.get<AssistantExtension>(ExtensionType.Assistant)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user