* fix: update new api from cortex to support 0.5.0 Signed-off-by: James <namnh0122@gmail.com> * fix stop button for streaming Signed-off-by: James <namnh0122@gmail.com> * fix stop inference for nonstreaming Signed-off-by: James <namnh0122@gmail.com> * chore: remove umami prevent tracking call to vercel Signed-off-by: James <namnh0122@gmail.com> * add warning modal when running more than 2 model concurrently Signed-off-by: James <namnh0122@gmail.com> * fix: skip summarize if abort Signed-off-by: James <namnh0122@gmail.com> * 0.5.0-3 * add inference error popup Signed-off-by: James <namnh0122@gmail.com> * add back import local model Signed-off-by: James <namnh0122@gmail.com> * fix: max token issue (#3225) Signed-off-by: James <namnh0122@gmail.com> * format status Signed-off-by: James <namnh0122@gmail.com> * fix migration missing instructions Signed-off-by: James <namnh0122@gmail.com> * fix: wait for cortex process overlay should be on top (#3224) * fix: wait for cortex process overlay should be on top * chore: update cortex.js * Cortex 0.5.0-5 * add import model to my model screen Signed-off-by: James <namnh0122@gmail.com> * fix: should migrate symlink models (#3226) * fix import on windows (#3229) Signed-off-by: James <namnh0122@gmail.com> * fix yarn lint Signed-off-by: James <namnh0122@gmail.com> * fix: clean up port before start jan (#3232) Signed-off-by: James <namnh0122@gmail.com> --------- Signed-off-by: James <namnh0122@gmail.com> Co-authored-by: Van Pham <64197333+Van-QA@users.noreply.github.com> Co-authored-by: Louis <louis@jan.ai>
102 lines
3.3 KiB
TypeScript
102 lines
3.3 KiB
TypeScript
import { useState } from 'react'
|
|
|
|
import { Button, useMediaQuery } from '@janhq/joi'
|
|
import { useAtom, useAtomValue, useSetAtom } from 'jotai'
|
|
import { SettingsIcon, ChevronUpIcon, Settings2Icon } from 'lucide-react'
|
|
|
|
import { twMerge } from 'tailwind-merge'
|
|
|
|
import ModelDropdown from '@/containers/ModelDropdown'
|
|
|
|
import ChatActionButton from './ChatActionButton'
|
|
import ChatTextInput from './ChatTextInput'
|
|
|
|
import { showRightPanelAtom } from '@/helpers/atoms/App.atom'
|
|
|
|
import { getActiveThreadIdAtom } from '@/helpers/atoms/Thread.atom'
|
|
import { activeTabThreadRightPanelAtom } from '@/helpers/atoms/ThreadRightPanel.atom'
|
|
|
|
type Props = {
|
|
sendMessage: (message: string) => void
|
|
stopInference: () => void
|
|
}
|
|
|
|
const ChatInput: React.FC<Props> = ({ sendMessage, stopInference }) => {
|
|
const setActiveTabThreadRightPanel = useSetAtom(activeTabThreadRightPanelAtom)
|
|
const activeThreadId = useAtomValue(getActiveThreadIdAtom)
|
|
const [activeSetting, setActiveSetting] = useState(false)
|
|
const [showRightPanel, setShowRightPanel] = useAtom(showRightPanelAtom)
|
|
|
|
const matches = useMediaQuery('(max-width: 880px)')
|
|
|
|
return (
|
|
<div className="relative p-4 pb-2">
|
|
<div className="relative flex w-full flex-col">
|
|
<ChatTextInput
|
|
isSettingActive={activeSetting}
|
|
onSendMessageClick={sendMessage}
|
|
/>
|
|
|
|
<div className={twMerge('absolute right-3 top-1.5')}>
|
|
<div className="flex items-center gap-x-4">
|
|
{!activeSetting && (
|
|
<div className="flex h-8 items-center">
|
|
<Button
|
|
theme="icon"
|
|
onClick={() => setActiveSetting(!activeSetting)}
|
|
>
|
|
<SettingsIcon
|
|
size={18}
|
|
className="text-[hsla(var(--text-secondary))]"
|
|
/>
|
|
</Button>
|
|
</div>
|
|
)}
|
|
<ChatActionButton
|
|
onStopInferenceClick={stopInference}
|
|
onSendMessageClick={sendMessage}
|
|
/>
|
|
</div>
|
|
</div>
|
|
|
|
{activeSetting && (
|
|
<div
|
|
className={twMerge(
|
|
'absolute bottom-[6px] left-[1px] flex w-[calc(100%-2px)] items-center justify-between rounded-lg bg-[hsla(var(--textarea-bg))] p-3',
|
|
!activeThreadId && 'bg-transparent'
|
|
)}
|
|
>
|
|
<div className="flex items-center gap-x-3">
|
|
<ModelDropdown chatInputMode />
|
|
<Button
|
|
theme="icon"
|
|
onClick={() => {
|
|
setActiveTabThreadRightPanel('model')
|
|
if (matches) {
|
|
setShowRightPanel(!showRightPanel)
|
|
} else if (!showRightPanel) {
|
|
setShowRightPanel(true)
|
|
}
|
|
}}
|
|
>
|
|
<Settings2Icon
|
|
size={16}
|
|
className="flex-shrink-0 cursor-pointer text-[hsla(var(--text-secondary))]"
|
|
/>
|
|
</Button>
|
|
</div>
|
|
<Button theme="icon" onClick={() => setActiveSetting(false)}>
|
|
<ChevronUpIcon
|
|
size={16}
|
|
className="cursor-pointer text-[hsla(var(--text-secondary))]"
|
|
/>
|
|
</Button>
|
|
</div>
|
|
)}
|
|
</div>
|
|
</div>
|
|
)
|
|
}
|
|
|
|
export default ChatInput
|