Skip to content

Commit 07c819f

Browse files
vid277skeptrunedev
authored andcommitted
feature: choose search type in chat
1 parent 527b4a2 commit 07c819f

File tree

1 file changed

+37
-0
lines changed

1 file changed

+37
-0
lines changed

frontends/chat/src/components/Layouts/MainLayout.tsx

+37
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,24 @@ const getFiltersFromStorage = (datasetId: string) => {
4242
return parsedFilters;
4343
};
4444

45+
const bm25Active = import.meta.env.VITE_BM25_ACTIVE as unknown as string;
46+
47+
const default_settings = [
48+
{ name: "Hybrid", route: "hybrid" },
49+
{
50+
name: "FullText",
51+
route: "fulltext",
52+
},
53+
{
54+
name: "Semantic",
55+
route: "semantic",
56+
},
57+
];
58+
59+
if (bm25Active) {
60+
default_settings.push({ name: "BM25", route: "bm25" });
61+
}
62+
4563
const MainLayout = (props: LayoutProps) => {
4664
const apiHost = import.meta.env.VITE_API_HOST as unknown as string;
4765

@@ -72,6 +90,7 @@ const MainLayout = (props: LayoutProps) => {
7290
const [completionAbortController, setCompletionAbortController] =
7391
createSignal<AbortController>(new AbortController());
7492
const [showFilterModal, setShowFilterModal] = createSignal<boolean>(false);
93+
const [searchType, setSearchType] = createSignal<string | null>("hybrid");
7594

7695
const handleReader = async (
7796
reader: ReadableStreamDefaultReader<Uint8Array>,
@@ -201,6 +220,7 @@ const MainLayout = (props: LayoutProps) => {
201220
llm_options: {
202221
completion_first: streamCompletionsFirst(),
203222
},
223+
search_type: searchType(),
204224
}),
205225
signal: completionAbortController().signal,
206226
});
@@ -460,6 +480,23 @@ const MainLayout = (props: LayoutProps) => {
460480
}}
461481
/>
462482
</div>
483+
<div class="flex w-full items-center gap-x-2">
484+
<label for="search_option">Search Type:</label>
485+
<select
486+
id="search_option"
487+
class="w-1/6 rounded-md border border-neutral-300 bg-neutral-100 p-1 dark:border-neutral-900 dark:bg-neutral-700"
488+
value={searchType() ?? ""}
489+
onChange={(e) => {
490+
setSearchType(e.target.value);
491+
}}
492+
>
493+
<For each={default_settings}>
494+
{(setting) => (
495+
<option value={setting.route}>{setting.name}</option>
496+
)}
497+
</For>
498+
</select>
499+
</div>
463500
<div class="flex w-full items-center gap-x-2">
464501
<label for="system_prompt">System Prompt:</label>
465502
<input

0 commit comments

Comments
 (0)