chore: Update new model.json with multiple binaries feat: Add updates for handling multiple model binaries chore: jan can see Update Model.json (#1005) * add(mixtral): add model.json for mixtral * archived some models + update the model.json * add(model): add pandora 10.7b * fix(model): update description * fix(model): pump vers and change the featured model to trinity * fix(model): archive neuralchat * fix(model): decapriated all old models * fix(trinity): add cover image and change description * fix(trinity): update cover png * add(pandora): cover image * fix(pandora): cover image * add(mixtral): add model.json for mixtral * archived some models + update the model.json * add(model): add pandora 10.7b * fix(model): update description * fix(model): pump vers and change the featured model to trinity * fix(model): archive neuralchat * fix(model): decapriated all old models * fix(trinity): add cover image and change description * fix(trinity): update cover png * add(pandora): cover image * fix(pandora): cover image * chore: model desc nits * fix(models): adjust the size for solars and pandoras * add(mixtral): description --------- Co-authored-by: 0xSage <n@pragmatic.vc> chore: reformat model.json and use new template fix(Model): download/abort model (#1163) * fix(Model): download/abort model * fix: image preview Signed-off-by: James <james@jan.ai> --------- Signed-off-by: James <james@jan.ai> Co-authored-by: James <james@jan.ai> Co-authored-by: Louis <louis@jan.ai> add preview and reduce time re-render all chat screen Signed-off-by: James <james@jan.ai> store files under thread_id/files Signed-off-by: James <james@jan.ai> fix: Update llava 1.5 size fix: Nitro extension path resolver feat: Add upload preview clearance chore: Update FileType to multiple targets fix: delete file preview once new thread created chore: Add langchain import support storing pdf file Signed-off-by: James <james@jan.ai> feat: add retrieval tool in node runtime fix: import module done Co-authored-by: Louis <louis-jan@users.noreply.github.com> feat: Add type assistant tool chore: Add tool_retrieval_enabled to InferenceEngine chore: Add AssistantTool to thread entity chore: refactor tool retrieval base class feat: Add handler for assistant with rag enabled chore: Update inferenceEngine type properly chore: Update inferenceEngine type properly fix: Update retrieval tool chore: main entry correction refactor: tsconfig files chore: Update ModelRuntimeParams type refactor: Remove unused files fix: wip chore: remove unused console.log for FileUploadPreview fix: Update mapping correctly for engine and proxyEngine feat: Add proxyEngine to type ModelInfo fix: WIP with test route fix: Add bundleDependencies to package.json chore: remove conversational history memory fix: refactor data passing reafactor: remove unused code fix: Update module chore: export import correction fix conflict Signed-off-by: James <james@jan.ai> fix: resolve after rebased fix: Update llava 1.5 model json feat: Add bakllava 1 model json refactor: node module export, ES syntax and langchain import fix: WIP fix: WIP fix: WIP fix: external module import fix: WIP Add UI attachment fot file upload Prepare Thumbnail UI image chore: rebase model folder to dev branch chore: remove multiple binaries related commits fix: remove multiple binaries related commits part 2 fix: Remove transformer.js related deps Fix truncate file name attachment remove unused code image preview attachment fix: remove multi binaries error chore: remove commented code for ModelArtifacts type Dropzone for drag and drop attachment Avoid conditional showing 0 using length fix symbol windows avoid undefined tools fix: add tool retrieval to true by default and disable the change chore: remove unused code fix: Enable nitro embedding by default fix: Update code WIP with nitro embedding chore: remove unused running function fix: assistant extension missing module feat: Retrieval ingest, query and reforward fix: Update hnswlib version conflict fix: Add tool settings fix: Update path to thread_id/memory fix: Add support for nitro embedding usage fix: RAG does not work with plain content message fix(Model): #1662 imported model does not use gpu (#1723) Signed-off-by: James <james@jan.ai> Co-authored-by: James <james@jan.ai> feat: allow users to update retrieval settings chore: pass thread assistant settings to assistant extensions chore: eslint fix fix bug border right panel showing in thread while not have active thread Update setting layout retrieval assistant Renaming file settingcomponent change default value in core extention add fake loader generate response fix conditional fake loader remove unused import Proper error message on file typr fix: loading indicator fix: chunk size and overlap constraint conditional drag and drop when retrieval off fix: enable retrieval middleware as soon as its tool is enabled fix: configure embedding engine according to request fix: Retrieval false by default fix: engine json chore: migrate assistant disabled collapse panel when retrieval or children null chore: remove unused log chore: Bump nitro version to 0.2.14 for batch embedding chore: remove unused console.log
219 lines
7.9 KiB
TypeScript
219 lines
7.9 KiB
TypeScript
import { useEffect } from 'react'
|
|
|
|
import {
|
|
Modal,
|
|
ModalTrigger,
|
|
ModalClose,
|
|
ModalFooter,
|
|
ModalPortal,
|
|
ModalContent,
|
|
ModalHeader,
|
|
ModalTitle,
|
|
Button,
|
|
} from '@janhq/uikit'
|
|
|
|
import { motion as m } from 'framer-motion'
|
|
import { useAtomValue } from 'jotai'
|
|
import {
|
|
GalleryHorizontalEndIcon,
|
|
MoreVerticalIcon,
|
|
Trash2Icon,
|
|
Paintbrush,
|
|
} from 'lucide-react'
|
|
|
|
import { twMerge } from 'tailwind-merge'
|
|
|
|
import { useCreateNewThread } from '@/hooks/useCreateNewThread'
|
|
import useDeleteThread from '@/hooks/useDeleteThread'
|
|
|
|
import useGetAssistants from '@/hooks/useGetAssistants'
|
|
import { useGetDownloadedModels } from '@/hooks/useGetDownloadedModels'
|
|
import useSetActiveThread from '@/hooks/useSetActiveThread'
|
|
|
|
import useThreads from '@/hooks/useThreads'
|
|
|
|
import { displayDate } from '@/utils/datetime'
|
|
|
|
import {
|
|
activeThreadAtom,
|
|
threadStatesAtom,
|
|
threadsAtom,
|
|
} from '@/helpers/atoms/Thread.atom'
|
|
|
|
export default function ThreadList() {
|
|
const threads = useAtomValue(threadsAtom)
|
|
const threadStates = useAtomValue(threadStatesAtom)
|
|
const { getThreads } = useThreads()
|
|
const { assistants } = useGetAssistants()
|
|
const { requestCreateNewThread } = useCreateNewThread()
|
|
const activeThread = useAtomValue(activeThreadAtom)
|
|
const { deleteThread, cleanThread } = useDeleteThread()
|
|
const { downloadedModels } = useGetDownloadedModels()
|
|
|
|
const { activeThreadId, setActiveThread: onThreadClick } =
|
|
useSetActiveThread()
|
|
|
|
useEffect(() => {
|
|
getThreads()
|
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
}, [])
|
|
|
|
useEffect(() => {
|
|
if (
|
|
downloadedModels.length !== 0 &&
|
|
threads.length === 0 &&
|
|
assistants.length !== 0 &&
|
|
!activeThread
|
|
) {
|
|
requestCreateNewThread(assistants[0])
|
|
}
|
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
}, [assistants, threads, downloadedModels, activeThread])
|
|
|
|
return (
|
|
<div className="px-3 py-4">
|
|
{threads.length === 0 ? (
|
|
<div className="px-4 py-8 text-center">
|
|
<GalleryHorizontalEndIcon
|
|
size={26}
|
|
className="mx-auto mb-3 text-muted-foreground"
|
|
/>
|
|
<h2 className="font-semibold">No Thread History</h2>
|
|
</div>
|
|
) : (
|
|
threads.map((thread, i) => {
|
|
const lastMessage =
|
|
threadStates[thread.id]?.lastMessage ?? 'No new message'
|
|
|
|
return (
|
|
<div
|
|
key={i}
|
|
className={twMerge(
|
|
`group/message relative mb-1 flex cursor-pointer flex-col transition-all hover:rounded-lg hover:bg-gray-100 hover:dark:bg-secondary/50`
|
|
)}
|
|
onClick={() => {
|
|
onThreadClick(thread)
|
|
}}
|
|
>
|
|
<div className="relative z-10 p-4 py-4">
|
|
<div className="flex justify-between">
|
|
<h2 className="line-clamp-1 font-bold">{thread.title}</h2>
|
|
<p className="mb-1 line-clamp-1 text-xs leading-5 text-muted-foreground">
|
|
{thread.updated &&
|
|
displayDate(new Date(thread.updated).getTime())}
|
|
</p>
|
|
</div>
|
|
<p className="mt-1 line-clamp-1 text-xs text-gray-700 group-hover/message:max-w-[160px] dark:text-gray-300">
|
|
{lastMessage || 'No new message'}
|
|
</p>
|
|
</div>
|
|
<div
|
|
className={twMerge(
|
|
`group/icon invisible absolute bottom-2 right-2 z-20 rounded-lg p-1 text-muted-foreground hover:bg-gray-200 group-hover/message:visible hover:dark:bg-secondary`
|
|
)}
|
|
>
|
|
<MoreVerticalIcon />
|
|
<div className="invisible absolute right-0 z-20 w-40 overflow-hidden rounded-lg border border-border bg-background shadow-lg group-hover/icon:visible">
|
|
<Modal>
|
|
<ModalTrigger asChild onClick={(e) => e.stopPropagation()}>
|
|
<div className="flex cursor-pointer items-center space-x-2 px-4 py-2 hover:bg-secondary">
|
|
<Paintbrush
|
|
size={16}
|
|
className="text-muted-foreground"
|
|
/>
|
|
<span className="text-bold text-black dark:text-muted-foreground">
|
|
Clean thread
|
|
</span>
|
|
</div>
|
|
</ModalTrigger>
|
|
<ModalPortal />
|
|
<ModalContent>
|
|
<ModalHeader>
|
|
<ModalTitle>Clean Thread</ModalTitle>
|
|
</ModalHeader>
|
|
<p>Are you sure you want to clean this thread?</p>
|
|
<ModalFooter>
|
|
<div className="flex gap-x-2">
|
|
<ModalClose
|
|
asChild
|
|
onClick={(e) => e.stopPropagation()}
|
|
>
|
|
<Button themes="ghost">No</Button>
|
|
</ModalClose>
|
|
<ModalClose asChild>
|
|
<Button
|
|
themes="danger"
|
|
onClick={(e) => {
|
|
e.stopPropagation()
|
|
cleanThread(thread.id)
|
|
}}
|
|
autoFocus
|
|
>
|
|
Yes
|
|
</Button>
|
|
</ModalClose>
|
|
</div>
|
|
</ModalFooter>
|
|
</ModalContent>
|
|
</Modal>
|
|
<Modal>
|
|
<ModalTrigger asChild onClick={(e) => e.stopPropagation()}>
|
|
<div className="flex cursor-pointer items-center space-x-2 px-4 py-2 hover:bg-secondary">
|
|
<Trash2Icon
|
|
size={16}
|
|
className="text-muted-foreground"
|
|
/>
|
|
<span className="text-bold text-black dark:text-muted-foreground">
|
|
Delete thread
|
|
</span>
|
|
</div>
|
|
</ModalTrigger>
|
|
<ModalPortal />
|
|
<ModalContent>
|
|
<ModalHeader>
|
|
<ModalTitle>Delete Thread</ModalTitle>
|
|
</ModalHeader>
|
|
<p>
|
|
Are you sure you want to delete this thread? This action
|
|
cannot be undone.
|
|
</p>
|
|
<ModalFooter>
|
|
<div className="flex gap-x-2">
|
|
<ModalClose
|
|
asChild
|
|
onClick={(e) => e.stopPropagation()}
|
|
>
|
|
<Button themes="ghost">No</Button>
|
|
</ModalClose>
|
|
<ModalClose asChild>
|
|
<Button
|
|
autoFocus
|
|
themes="danger"
|
|
onClick={(e) => {
|
|
e.stopPropagation()
|
|
deleteThread(thread.id)
|
|
}}
|
|
>
|
|
Yes
|
|
</Button>
|
|
</ModalClose>
|
|
</div>
|
|
</ModalFooter>
|
|
</ModalContent>
|
|
</Modal>
|
|
</div>
|
|
</div>
|
|
{activeThreadId === thread.id && (
|
|
<m.div
|
|
className="absolute inset-0 left-0 h-full w-full rounded-lg bg-gray-100 p-4 dark:bg-secondary/50"
|
|
layoutId="active-thread"
|
|
/>
|
|
)}
|
|
</div>
|
|
)
|
|
})
|
|
)}
|
|
</div>
|
|
)
|
|
}
|