SurfSense/surfsense_web/components/chat/ChatInterface.tsx

57 lines
1.7 KiB
TypeScript
Raw Normal View History

"use client";
import {
type ChatHandler,
ChatSection as LlamaIndexChatSection,
} from "@llamaindex/chat-ui";
2025-10-22 16:35:15 +02:00
import { useParams } from "next/navigation";
2025-07-27 10:41:15 -07:00
import { ChatInputUI } from "@/components/chat/ChatInputGroup";
import { ChatMessagesUI } from "@/components/chat/ChatMessages";
2025-07-27 10:41:15 -07:00
import type { Document } from "@/hooks/use-documents";
interface ChatInterfaceProps {
handler: ChatHandler;
onDocumentSelectionChange?: (documents: Document[]) => void;
selectedDocuments?: Document[];
onConnectorSelectionChange?: (connectorTypes: string[]) => void;
selectedConnectors?: string[];
searchMode?: "DOCUMENTS" | "CHUNKS";
onSearchModeChange?: (mode: "DOCUMENTS" | "CHUNKS") => void;
topK?: number;
onTopKChange?: (topK: number) => void;
}
2025-07-25 18:06:48 -07:00
export default function ChatInterface({
handler,
onDocumentSelectionChange,
selectedDocuments = [],
onConnectorSelectionChange,
selectedConnectors = [],
searchMode,
onSearchModeChange,
topK = 10,
onTopKChange,
}: ChatInterfaceProps) {
const { chat_id, search_space_id } = useParams();
2025-07-25 18:06:48 -07:00
return (
2025-11-14 21:53:46 -08:00
<LlamaIndexChatSection handler={handler} className="flex h-full max-w-7xl mx-auto">
2025-11-11 04:02:04 +02:00
<div className="flex grow-1 flex-col">
2025-07-25 18:06:48 -07:00
<ChatMessagesUI />
2025-11-14 21:53:46 -08:00
<div className="border-1 rounded-4xl p-2">
2025-07-25 18:06:48 -07:00
<ChatInputUI
onDocumentSelectionChange={onDocumentSelectionChange}
selectedDocuments={selectedDocuments}
onConnectorSelectionChange={onConnectorSelectionChange}
selectedConnectors={selectedConnectors}
searchMode={searchMode}
onSearchModeChange={onSearchModeChange}
2025-11-06 13:25:05 -08:00
topK={topK}
onTopKChange={onTopKChange}
2025-07-25 18:06:48 -07:00
/>
</div>
</div>
</LlamaIndexChatSection>
);
}