mirror of
https://github.com/MODSetter/SurfSense.git
synced 2026-06-16 21:05:20 +02:00
feat(roadmap-1.2): removed SearchMode enum and combined hybrid search
This commit is contained in:
parent
dc92f313e7
commit
08fb488995
10 changed files with 331 additions and 548 deletions
|
|
@ -9,8 +9,8 @@ import { activeChatAtom } from "@/atoms/chats/chat-query.atoms";
|
|||
import { activeChatIdAtom } from "@/atoms/chats/ui.atoms";
|
||||
import { documentTypeCountsAtom } from "@/atoms/documents/document-query.atoms";
|
||||
import ChatInterface from "@/components/chat/ChatInterface";
|
||||
import type { Document } from "@/contracts/types/document.types";
|
||||
import { useChatState } from "@/hooks/use-chat";
|
||||
import type { Document } from "@/hooks/use-documents";
|
||||
import { useSearchSourceConnectors } from "@/hooks/use-search-source-connectors";
|
||||
|
||||
export default function ResearcherPage() {
|
||||
|
|
@ -31,8 +31,6 @@ export default function ResearcherPage() {
|
|||
|
||||
const {
|
||||
token,
|
||||
searchMode,
|
||||
setSearchMode,
|
||||
researchMode,
|
||||
selectedConnectors,
|
||||
setSelectedConnectors,
|
||||
|
|
@ -84,7 +82,6 @@ export default function ResearcherPage() {
|
|||
interface ChatState {
|
||||
selectedDocuments: Document[];
|
||||
selectedConnectors: string[];
|
||||
searchMode: "DOCUMENTS" | "CHUNKS";
|
||||
researchMode: "QNA"; // Always QNA mode
|
||||
topK: number;
|
||||
}
|
||||
|
|
@ -124,7 +121,6 @@ export default function ResearcherPage() {
|
|||
search_space_id: search_space_id,
|
||||
selected_connectors: connectorTypes,
|
||||
research_mode: researchMode,
|
||||
search_mode: searchMode,
|
||||
document_ids_to_add_in_context: documentIds,
|
||||
top_k: topK,
|
||||
},
|
||||
|
|
@ -155,7 +151,6 @@ export default function ResearcherPage() {
|
|||
storeChatState(search_space_id as string, String(newChat.id), {
|
||||
selectedDocuments,
|
||||
selectedConnectors,
|
||||
searchMode,
|
||||
researchMode,
|
||||
topK,
|
||||
});
|
||||
|
|
@ -203,7 +198,6 @@ export default function ResearcherPage() {
|
|||
if (restoredState) {
|
||||
setSelectedDocuments(restoredState.selectedDocuments);
|
||||
setSelectedConnectors(restoredState.selectedConnectors);
|
||||
setSearchMode(restoredState.searchMode);
|
||||
setTopK(restoredState.topK);
|
||||
// researchMode is always "QNA", no need to restore
|
||||
}
|
||||
|
|
@ -214,7 +208,6 @@ export default function ResearcherPage() {
|
|||
search_space_id,
|
||||
setSelectedDocuments,
|
||||
setSelectedConnectors,
|
||||
setSearchMode,
|
||||
setTopK,
|
||||
]);
|
||||
|
||||
|
|
@ -287,8 +280,6 @@ export default function ResearcherPage() {
|
|||
selectedDocuments={selectedDocuments}
|
||||
onConnectorSelectionChange={setSelectedConnectors}
|
||||
selectedConnectors={selectedConnectors}
|
||||
searchMode={searchMode}
|
||||
onSearchModeChange={setSearchMode}
|
||||
topK={topK}
|
||||
onTopKChange={setTopK}
|
||||
/>
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@ import {
|
|||
} from "@/components/ui/select";
|
||||
import { Tooltip, TooltipContent, TooltipProvider, TooltipTrigger } from "@/components/ui/tooltip";
|
||||
import { getConnectorIcon } from "@/contracts/enums/connectorIcons";
|
||||
import type { Document } from "@/hooks/use-documents";
|
||||
import type { Document } from "@/contracts/types/document.types";
|
||||
import { useGlobalLLMConfigs, useLLMConfigs, useLLMPreferences } from "@/hooks/use-llm-configs";
|
||||
import { useSearchSourceConnectors } from "@/hooks/use-search-source-connectors";
|
||||
|
||||
|
|
@ -422,58 +422,6 @@ const ConnectorSelector = React.memo(
|
|||
|
||||
ConnectorSelector.displayName = "ConnectorSelector";
|
||||
|
||||
const SearchModeSelector = React.memo(
|
||||
({
|
||||
searchMode,
|
||||
onSearchModeChange,
|
||||
}: {
|
||||
searchMode?: "DOCUMENTS" | "CHUNKS";
|
||||
onSearchModeChange?: (mode: "DOCUMENTS" | "CHUNKS") => void;
|
||||
}) => {
|
||||
const handleDocumentsClick = React.useCallback(() => {
|
||||
onSearchModeChange?.("DOCUMENTS");
|
||||
}, [onSearchModeChange]);
|
||||
|
||||
const handleChunksClick = React.useCallback(() => {
|
||||
onSearchModeChange?.("CHUNKS");
|
||||
}, [onSearchModeChange]);
|
||||
|
||||
return (
|
||||
<div className="flex items-center gap-2">
|
||||
<div className="inline-flex h-9 items-center justify-center rounded-lg bg-muted p-1 text-muted-foreground">
|
||||
<button
|
||||
type="button"
|
||||
onClick={handleDocumentsClick}
|
||||
className={`inline-flex items-center justify-center whitespace-nowrap rounded-md px-3 py-1.5 text-xs font-medium transition-all focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 ${
|
||||
searchMode === "DOCUMENTS"
|
||||
? "bg-background text-foreground shadow-sm"
|
||||
: "hover:bg-background/50 hover:text-foreground"
|
||||
}`}
|
||||
>
|
||||
<FolderOpen className="h-3.5 w-3.5 mr-1.5" />
|
||||
<span className="hidden sm:inline">Documents</span>
|
||||
<span className="sm:hidden">Docs</span>
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
onClick={handleChunksClick}
|
||||
className={`inline-flex items-center justify-center whitespace-nowrap rounded-md px-3 py-1.5 text-xs font-medium transition-all focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 ${
|
||||
searchMode === "CHUNKS"
|
||||
? "bg-background text-foreground shadow-sm"
|
||||
: "hover:bg-background/50 hover:text-foreground"
|
||||
}`}
|
||||
>
|
||||
<Zap className="h-3.5 w-3.5 mr-1.5" />
|
||||
Chunks
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
);
|
||||
|
||||
SearchModeSelector.displayName = "SearchModeSelector";
|
||||
|
||||
const TopKSelector = React.memo(
|
||||
({ topK = 10, onTopKChange }: { topK?: number; onTopKChange?: (topK: number) => void }) => {
|
||||
const MIN_VALUE = 1;
|
||||
|
|
@ -808,8 +756,6 @@ const CustomChatInputOptions = React.memo(
|
|||
selectedDocuments,
|
||||
onConnectorSelectionChange,
|
||||
selectedConnectors,
|
||||
searchMode,
|
||||
onSearchModeChange,
|
||||
topK,
|
||||
onTopKChange,
|
||||
}: {
|
||||
|
|
@ -817,8 +763,6 @@ const CustomChatInputOptions = React.memo(
|
|||
selectedDocuments?: Document[];
|
||||
onConnectorSelectionChange?: (connectorTypes: string[]) => void;
|
||||
selectedConnectors?: string[];
|
||||
searchMode?: "DOCUMENTS" | "CHUNKS";
|
||||
onSearchModeChange?: (mode: "DOCUMENTS" | "CHUNKS") => void;
|
||||
topK?: number;
|
||||
onTopKChange?: (topK: number) => void;
|
||||
}) => {
|
||||
|
|
@ -845,8 +789,6 @@ const CustomChatInputOptions = React.memo(
|
|||
</Suspense>
|
||||
</div>
|
||||
<div className="h-4 w-px bg-border hidden sm:block" />
|
||||
<SearchModeSelector searchMode={searchMode} onSearchModeChange={onSearchModeChange} />
|
||||
<div className="h-4 w-px bg-border hidden sm:block" />
|
||||
<TopKSelector topK={topK} onTopKChange={onTopKChange} />
|
||||
<div className="h-4 w-px bg-border hidden sm:block" />
|
||||
<LLMSelector />
|
||||
|
|
@ -863,8 +805,6 @@ export const ChatInputUI = React.memo(
|
|||
selectedDocuments,
|
||||
onConnectorSelectionChange,
|
||||
selectedConnectors,
|
||||
searchMode,
|
||||
onSearchModeChange,
|
||||
topK,
|
||||
onTopKChange,
|
||||
}: {
|
||||
|
|
@ -872,8 +812,6 @@ export const ChatInputUI = React.memo(
|
|||
selectedDocuments?: Document[];
|
||||
onConnectorSelectionChange?: (connectorTypes: string[]) => void;
|
||||
selectedConnectors?: string[];
|
||||
searchMode?: "DOCUMENTS" | "CHUNKS";
|
||||
onSearchModeChange?: (mode: "DOCUMENTS" | "CHUNKS") => void;
|
||||
topK?: number;
|
||||
onTopKChange?: (topK: number) => void;
|
||||
}) => {
|
||||
|
|
@ -888,8 +826,6 @@ export const ChatInputUI = React.memo(
|
|||
selectedDocuments={selectedDocuments}
|
||||
onConnectorSelectionChange={onConnectorSelectionChange}
|
||||
selectedConnectors={selectedConnectors}
|
||||
searchMode={searchMode}
|
||||
onSearchModeChange={onSearchModeChange}
|
||||
topK={topK}
|
||||
onTopKChange={onTopKChange}
|
||||
/>
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ import { type ChatHandler, ChatSection as LlamaIndexChatSection } from "@llamain
|
|||
import { useParams } from "next/navigation";
|
||||
import { ChatInputUI } from "@/components/chat/ChatInputGroup";
|
||||
import { ChatMessagesUI } from "@/components/chat/ChatMessages";
|
||||
import type { Document } from "@/hooks/use-documents";
|
||||
import type { Document } from "@/contracts/types/document.types";
|
||||
|
||||
interface ChatInterfaceProps {
|
||||
handler: ChatHandler;
|
||||
|
|
@ -12,8 +12,6 @@ interface ChatInterfaceProps {
|
|||
selectedDocuments?: Document[];
|
||||
onConnectorSelectionChange?: (connectorTypes: string[]) => void;
|
||||
selectedConnectors?: string[];
|
||||
searchMode?: "DOCUMENTS" | "CHUNKS";
|
||||
onSearchModeChange?: (mode: "DOCUMENTS" | "CHUNKS") => void;
|
||||
topK?: number;
|
||||
onTopKChange?: (topK: number) => void;
|
||||
}
|
||||
|
|
@ -24,8 +22,6 @@ export default function ChatInterface({
|
|||
selectedDocuments = [],
|
||||
onConnectorSelectionChange,
|
||||
selectedConnectors = [],
|
||||
searchMode,
|
||||
onSearchModeChange,
|
||||
topK = 10,
|
||||
onTopKChange,
|
||||
}: ChatInterfaceProps) {
|
||||
|
|
@ -41,8 +37,6 @@ export default function ChatInterface({
|
|||
selectedDocuments={selectedDocuments}
|
||||
onConnectorSelectionChange={onConnectorSelectionChange}
|
||||
selectedConnectors={selectedConnectors}
|
||||
searchMode={searchMode}
|
||||
onSearchModeChange={onSearchModeChange}
|
||||
topK={topK}
|
||||
onTopKChange={onTopKChange}
|
||||
/>
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ import type { Message } from "@ai-sdk/react";
|
|||
import { useCallback, useEffect, useState } from "react";
|
||||
import type { ChatDetails } from "@/app/dashboard/[search_space_id]/chats/chats-client";
|
||||
import type { ResearchMode } from "@/components/chat";
|
||||
import type { Document } from "@/hooks/use-documents";
|
||||
import type { Document } from "@/contracts/types/document.types";
|
||||
import { getBearerToken } from "@/lib/auth-utils";
|
||||
|
||||
interface UseChatStateProps {
|
||||
|
|
@ -16,7 +16,6 @@ export function useChatState({ chat_id }: UseChatStateProps) {
|
|||
const [currentChatId, setCurrentChatId] = useState<string | null>(chat_id || null);
|
||||
|
||||
// Chat configuration state
|
||||
const [searchMode, setSearchMode] = useState<"DOCUMENTS" | "CHUNKS">("DOCUMENTS");
|
||||
const [researchMode, setResearchMode] = useState<ResearchMode>("QNA");
|
||||
const [selectedConnectors, setSelectedConnectors] = useState<string[]>([]);
|
||||
const [selectedDocuments, setSelectedDocuments] = useState<Document[]>([]);
|
||||
|
|
@ -34,8 +33,6 @@ export function useChatState({ chat_id }: UseChatStateProps) {
|
|||
setIsLoading,
|
||||
currentChatId,
|
||||
setCurrentChatId,
|
||||
searchMode,
|
||||
setSearchMode,
|
||||
researchMode,
|
||||
setResearchMode,
|
||||
selectedConnectors,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue