* fix: reduce the number of api call Signed-off-by: James <james@jan.ai> * fix: download progress Signed-off-by: James <james@jan.ai> * chore: save blob * fix: server boot up * fix: download state not updating Signed-off-by: James <james@jan.ai> * fix: copy assets * Add Dockerfile CPU for Jan Server and Jan Web * Add Dockerfile GPU for Jan Server and Jan Web * feat: S3 adapter * Update check find count from ./pre-install and correct copy:asserts command * server add bundleDependencies @janhq/core * server add bundleDependencies @janhq/core * fix: update success/failed download state (#1945) * fix: update success/failed download state Signed-off-by: James <james@jan.ai> * fix: download model progress and state handling for both Desktop and Web --------- Signed-off-by: James <james@jan.ai> Co-authored-by: James <james@jan.ai> Co-authored-by: Louis <louis@jan.ai> * chore: refactor * fix: load models empty first time open * Add Docker compose * fix: assistants onUpdate --------- Signed-off-by: James <james@jan.ai> Co-authored-by: James <james@jan.ai> Co-authored-by: Hien To <tominhhien97@gmail.com> Co-authored-by: NamH <NamNh0122@gmail.com>
102 lines
3.1 KiB
TypeScript
102 lines
3.1 KiB
TypeScript
import { Fragment } from 'react'
|
|
|
|
import ScrollToBottom from 'react-scroll-to-bottom'
|
|
|
|
import { InferenceEngine, MessageStatus } from '@janhq/core'
|
|
import { Button } from '@janhq/uikit'
|
|
import { useAtomValue } from 'jotai'
|
|
|
|
import LogoMark from '@/containers/Brand/Logo/Mark'
|
|
|
|
import { MainViewState } from '@/constants/screens'
|
|
|
|
import { useMainViewState } from '@/hooks/useMainViewState'
|
|
|
|
import ChatItem from '../ChatItem'
|
|
|
|
import ErrorMessage from '../ErrorMessage'
|
|
|
|
import { getCurrentChatMessagesAtom } from '@/helpers/atoms/ChatMessage.atom'
|
|
import { downloadedModelsAtom } from '@/helpers/atoms/Model.atom'
|
|
|
|
const ChatBody: React.FC = () => {
|
|
const messages = useAtomValue(getCurrentChatMessagesAtom)
|
|
|
|
const downloadedModels = useAtomValue(downloadedModelsAtom)
|
|
|
|
const { setMainViewState } = useMainViewState()
|
|
|
|
if (downloadedModels.length === 0)
|
|
return (
|
|
<div className="mx-auto flex h-full w-3/4 flex-col items-center justify-center text-center">
|
|
<LogoMark
|
|
className="mx-auto mb-4 animate-wave"
|
|
width={56}
|
|
height={56}
|
|
/>
|
|
<h1 className="text-2xl font-bold">Welcome!</h1>
|
|
<p className="mt-1 text-base">You need to download your first model</p>
|
|
<Button
|
|
className="mt-4"
|
|
onClick={() => setMainViewState(MainViewState.Hub)}
|
|
>
|
|
Explore The Hub
|
|
</Button>
|
|
</div>
|
|
)
|
|
|
|
const showOnboardingStep =
|
|
downloadedModels.filter((e) => e.engine === InferenceEngine.nitro)
|
|
.length === 0
|
|
|
|
return (
|
|
<Fragment>
|
|
{messages.length === 0 ? (
|
|
<div className="mx-auto flex h-full w-3/4 flex-col items-center justify-center text-center">
|
|
<LogoMark
|
|
className="mx-auto mb-4 animate-wave"
|
|
width={56}
|
|
height={56}
|
|
/>
|
|
{showOnboardingStep ? (
|
|
<>
|
|
<p className="mt-1 text-base font-medium">
|
|
{`You don't have a local model yet.`}
|
|
</p>
|
|
<div className="w-auto px-4 py-2">
|
|
<Button
|
|
block
|
|
className="bg-blue-100 font-bold text-blue-600 hover:bg-blue-100 hover:text-blue-600"
|
|
onClick={() => setMainViewState(MainViewState.Hub)}
|
|
>
|
|
Explore The Hub
|
|
</Button>
|
|
</div>
|
|
</>
|
|
) : (
|
|
<p className="mt-1 text-base font-medium">How can I help you?</p>
|
|
)}
|
|
</div>
|
|
) : (
|
|
<ScrollToBottom className="flex h-full w-full flex-col">
|
|
{messages.map((message, index) => (
|
|
<div key={message.id}>
|
|
{(message.status !== MessageStatus.Pending ||
|
|
message.content.length > 0) && (
|
|
<ChatItem {...message} key={message.id} />
|
|
)}
|
|
{(message.status === MessageStatus.Error ||
|
|
message.status === MessageStatus.Stopped) &&
|
|
index === messages.length - 1 && (
|
|
<ErrorMessage message={message} />
|
|
)}
|
|
</div>
|
|
))}
|
|
</ScrollToBottom>
|
|
)}
|
|
</Fragment>
|
|
)
|
|
}
|
|
|
|
export default ChatBody
|