diff --git a/surfsense_web/components/chat/ChatInputGroup.tsx b/surfsense_web/components/chat/ChatInputGroup.tsx index c3877c108..866ac7b0f 100644 --- a/surfsense_web/components/chat/ChatInputGroup.tsx +++ b/surfsense_web/components/chat/ChatInputGroup.tsx @@ -334,9 +334,13 @@ ResearchModeSelector.displayName = "ResearchModeSelector"; const LLMSelector = React.memo(() => { const { search_space_id } = useParams(); const searchSpaceId = Number(search_space_id); - + const { llmConfigs, loading: llmLoading, error } = useLLMConfigs(searchSpaceId); - const { preferences, updatePreferences, loading: preferencesLoading } = useLLMPreferences(searchSpaceId); + const { + preferences, + updatePreferences, + loading: preferencesLoading, + } = useLLMPreferences(searchSpaceId); const isLoading = llmLoading || preferencesLoading; diff --git a/surfsense_web/components/inference-params-editor.tsx b/surfsense_web/components/inference-params-editor.tsx index df198cfa0..9ef2ec27a 100644 --- a/surfsense_web/components/inference-params-editor.tsx +++ b/surfsense_web/components/inference-params-editor.tsx @@ -1,138 +1,153 @@ "use client"; -import { useState } from "react"; import { Plus, Trash2 } from "lucide-react"; +import { useState } from "react"; import { Button } from "@/components/ui/button"; import { Input } from "@/components/ui/input"; import { Label } from "@/components/ui/label"; import { - Select, - SelectContent, - SelectItem, - SelectTrigger, - SelectValue, + Select, + SelectContent, + SelectItem, + SelectTrigger, + SelectValue, } from "@/components/ui/select"; interface InferenceParamsEditorProps { - params: Record; - setParams: (newParams: Record) => void; + params: Record; + setParams: (newParams: Record) => void; } const PARAM_KEYS = ["temperature", "max_tokens", "top_k", "top_p"] as const; -export default function InferenceParamsEditor({ - params, - setParams, -}: InferenceParamsEditorProps) { - const [selectedKey, setSelectedKey] = useState(""); - const [value, setValue] = useState(""); +export default function InferenceParamsEditor({ params, setParams }: InferenceParamsEditorProps) { + const [selectedKey, setSelectedKey] = useState(""); + const [value, setValue] = useState(""); - const handleAdd = () => { - if (!selectedKey || value === "") return; + const handleAdd = () => { + if (!selectedKey || value === "") return; - if (params[selectedKey]) { - alert(`${selectedKey} already exists`); - return; - } + if (params[selectedKey]) { + alert(`${selectedKey} already exists`); + return; + } - const numericValue = Number(value); + const numericValue = Number(value); - if ((selectedKey === "temperature" || selectedKey === "top_p") && (isNaN(numericValue) || numericValue < 0 || numericValue > 1)) { - alert("Value must be a number between 0 and 1"); - return; - } + if ( + (selectedKey === "temperature" || selectedKey === "top_p") && + (isNaN(numericValue) || numericValue < 0 || numericValue > 1) + ) { + alert("Value must be a number between 0 and 1"); + return; + } - if ((selectedKey === "max_tokens" || selectedKey === "top_k") && (!Number.isInteger(numericValue) || numericValue < 0)) { - alert("Value must be a non-negative integer"); - return; - } + if ( + (selectedKey === "max_tokens" || selectedKey === "top_k") && + (!Number.isInteger(numericValue) || numericValue < 0) + ) { + alert("Value must be a non-negative integer"); + return; + } - setParams({ - ...params, - [selectedKey]: isNaN(numericValue) ? value : numericValue, - }); + setParams({ + ...params, + [selectedKey]: isNaN(numericValue) ? value : numericValue, + }); - setSelectedKey(""); - setValue(""); - }; + setSelectedKey(""); + setValue(""); + }; - const handleDelete = (key: string) => { - const newParams = { ...params }; - delete newParams[key]; - setParams(newParams); - }; + const handleDelete = (key: string) => { + const newParams = { ...params }; + delete newParams[key]; + setParams(newParams); + }; - return ( -
-
-
- - -
+ return ( +
+
+
+ + +
-
- - setValue(e.target.value)} - className="w-full" - /> -
+
+ + setValue(e.target.value)} + className="w-full" + /> +
- -
+ +
-
+
- {Object.keys(params).length > 0 && ( -
- - - - - - - - - - {Object.entries(params).map(([key, val]) => ( - - - - - - ))} - -
KeyValueActions
{key}{val.toString()} - -
-
- )} -
- ); + {Object.keys(params).length > 0 && ( +
+ + + + + + + + + + {Object.entries(params).map(([key, val]) => ( + + + + + + ))} + +
+ Key + + Value + + Actions +
{key}{val.toString()} + +
+
+ )} +
+ ); } diff --git a/surfsense_web/components/onboard/add-provider-step.tsx b/surfsense_web/components/onboard/add-provider-step.tsx index 6517fe0a1..0086674d2 100644 --- a/surfsense_web/components/onboard/add-provider-step.tsx +++ b/surfsense_web/components/onboard/add-provider-step.tsx @@ -17,8 +17,8 @@ import { SelectTrigger, SelectValue, } from "@/components/ui/select"; -import { LLM_PROVIDERS } from "@/contracts/enums/llm-providers"; import { LANGUAGES } from "@/contracts/enums/languages"; +import { LLM_PROVIDERS } from "@/contracts/enums/llm-providers"; import { type CreateLLMConfig, useLLMConfigs } from "@/hooks/use-llm-configs"; import InferenceParamsEditor from "../inference-params-editor"; @@ -223,7 +223,6 @@ export function AddProviderStep({ - {formData.provider === "CUSTOM" && ( diff --git a/surfsense_web/drizzle.config.ts b/surfsense_web/drizzle.config.ts index fbd033a9e..bfc33ec9b 100644 --- a/surfsense_web/drizzle.config.ts +++ b/surfsense_web/drizzle.config.ts @@ -1,11 +1,11 @@ -import 'dotenv/config'; -import { defineConfig } from 'drizzle-kit'; +import "dotenv/config"; +import { defineConfig } from "drizzle-kit"; export default defineConfig({ - out: './drizzle', - schema: './app/db/schema.ts', - dialect: 'postgresql', - dbCredentials: { - url: process.env.DATABASE_URL!, - }, + out: "./drizzle", + schema: "./app/db/schema.ts", + dialect: "postgresql", + dbCredentials: { + url: process.env.DATABASE_URL!, + }, }); diff --git a/surfsense_web/hooks/use-connector-edit-page.ts b/surfsense_web/hooks/use-connector-edit-page.ts index ea6a3fe10..850f7e3e5 100644 --- a/surfsense_web/hooks/use-connector-edit-page.ts +++ b/surfsense_web/hooks/use-connector-edit-page.ts @@ -337,12 +337,7 @@ export function useConnectorEditPage(connectorId: number, searchSpaceId: string) const originalSafesearch = originalConfig.SEARXNG_SAFESEARCH; if (safesearchRaw) { const parsed = Number(safesearchRaw); - if ( - Number.isNaN(parsed) || - !Number.isInteger(parsed) || - parsed < 0 || - parsed > 2 - ) { + if (Number.isNaN(parsed) || !Number.isInteger(parsed) || parsed < 0 || parsed > 2) { toast.error("SearxNG SafeSearch must be 0, 1, or 2."); setIsSaving(false); return; @@ -521,10 +516,7 @@ export function useConnectorEditPage(connectorId: number, searchSpaceId: string) "SEARXNG_CATEGORIES", normalizeListInput(newlySavedConfig.SEARXNG_CATEGORIES).join(", ") ); - editForm.setValue( - "SEARXNG_LANGUAGE", - newlySavedConfig.SEARXNG_LANGUAGE || "" - ); + editForm.setValue("SEARXNG_LANGUAGE", newlySavedConfig.SEARXNG_LANGUAGE || ""); editForm.setValue( "SEARXNG_SAFESEARCH", newlySavedConfig.SEARXNG_SAFESEARCH === null ||