Add chat pannel

This commit is contained in:
CREDO23 2025-10-22 14:41:47 +02:00 committed by thierryverse
parent 5585cdf411
commit bc512ec089

View file

@ -1,9 +1,13 @@
"use client"; "use client";
import { type ChatHandler, ChatSection as LlamaIndexChatSection } from "@llamaindex/chat-ui"; import { type ChatHandler, ChatSection as LlamaIndexChatSection } from "@llamaindex/chat-ui";
import { PanelRight } from "lucide-react";
import { useState } from "react";
import type { ResearchMode } from "@/components/chat";
import { ChatInputUI } from "@/components/chat/ChatInputGroup"; import { ChatInputUI } from "@/components/chat/ChatInputGroup";
import { ChatMessagesUI } from "@/components/chat/ChatMessages"; import { ChatMessagesUI } from "@/components/chat/ChatMessages";
import type { Document } from "@/hooks/use-documents"; import type { Document } from "@/hooks/use-documents";
import { cn } from "@/lib/utils";
interface ChatInterfaceProps { interface ChatInterfaceProps {
handler: ChatHandler; handler: ChatHandler;
@ -24,19 +28,46 @@ export default function ChatInterface({
searchMode, searchMode,
onSearchModeChange, onSearchModeChange,
}: ChatInterfaceProps) { }: ChatInterfaceProps) {
const [isChatPannelOpen, setIsChatPannelOpen] = useState(false);
return ( return (
<LlamaIndexChatSection handler={handler} className="flex h-full"> <LlamaIndexChatSection handler={handler} className="flex h-full">
<div className="flex flex-1 flex-col"> <div className="flex gap-4 flex-1 w-full">
<ChatMessagesUI /> <div className="flex grow-1 flex-col">
<div className="border-t p-4"> <ChatMessagesUI />
<ChatInputUI <div className="border-t p-4">
onDocumentSelectionChange={onDocumentSelectionChange} <ChatInputUI
selectedDocuments={selectedDocuments} onDocumentSelectionChange={onDocumentSelectionChange}
onConnectorSelectionChange={onConnectorSelectionChange} selectedDocuments={selectedDocuments}
selectedConnectors={selectedConnectors} onConnectorSelectionChange={onConnectorSelectionChange}
searchMode={searchMode} selectedConnectors={selectedConnectors}
onSearchModeChange={onSearchModeChange} searchMode={searchMode}
/> onSearchModeChange={onSearchModeChange}
/>
</div>
</div>
<div
className={cn(
"border rounded-2xl shrink-0 flex flex-col h-full",
isChatPannelOpen ? "w-72" : "w-14"
)}
>
<div
className={cn(
"w-full border-b p-2 flex items-center ",
isChatPannelOpen ? "justify-end" : " justify-center "
)}
>
<button
type="button"
onClick={() => setIsChatPannelOpen(!isChatPannelOpen)}
className={cn(" shrink-0 rounded-full p-2 w-fit hover:bg-muted")}
>
<PanelRight className="h-5 w-5" strokeWidth={1.5} />
</button>
</div>
<div className="border-b rounded-lg p-2 grow-1">Chat pannel</div>
</div> </div>
</div> </div>
</LlamaIndexChatSection> </LlamaIndexChatSection>