From c59b1a34241e799965ff228fd695db813591b2ee Mon Sep 17 00:00:00 2001 From: rajgupta-ml Date: Fri, 29 Aug 2025 13:43:22 +0530 Subject: [PATCH] add: LLM local pref --- frontend/bun.lock | 3 +++ frontend/components/ui/model-selector.tsx | 5 ++++- frontend/components/ui/ui-input.tsx | 19 +++++++++++++++---- 3 files changed, 22 insertions(+), 5 deletions(-) diff --git a/frontend/bun.lock b/frontend/bun.lock index 6c2ff42a..bdbbcc32 100644 --- a/frontend/bun.lock +++ b/frontend/bun.lock @@ -39,6 +39,7 @@ "clsx": "^2.1.1", "cmdk": "^1.1.1", "framer-motion": "^12.16.0", + "input-otp": "^1.4.2", "lucide-react": "^0.514.0", "next": "^15.2.3", "next-auth": "5.0.0-beta.25", @@ -1012,6 +1013,8 @@ "inline-style-parser": ["inline-style-parser@0.2.4", "", {}, "sha512-0aO8FkhNZlj/ZIbNi7Lxxr12obT7cL1moPfE4tg1LkX7LlLfC6DeX4l2ZEud1ukP9jNQyNnfzQVqwbwmAATY4Q=="], + "input-otp": ["input-otp@1.4.2", "", { "peerDependencies": { "react": "^16.8 || ^17.0 || ^18.0 || ^19.0.0 || ^19.0.0-rc", "react-dom": "^16.8 || ^17.0 || ^18.0 || ^19.0.0 || ^19.0.0-rc" } }, "sha512-l3jWwYNvrEa6NTCt7BECfCm48GvwuZzkoeG3gBL2w4CHeOXW3eKFmf9UNYkNfYc3mxMrthMnxjIE07MT0zLBQA=="], + "internal-slot": ["internal-slot@1.1.0", "", { "dependencies": { "es-errors": "^1.3.0", "hasown": "^2.0.2", "side-channel": "^1.1.0" } }, "sha512-4gd7VpWNQNB4UKKCFFVcp1AVv+FMOgs9NKzjHKusc8jTMhd5eL1NqQqOpE0KzMds804/yHlglp3uxgluOqAPLw=="], "internmap": ["internmap@2.0.3", "", {}, "sha512-5Hh7Y1wQbvY5ooGgPbDaL5iYLAPzMTUrjMulskHLH6wnv/A+1q5rgEaiuqEjB+oxGXIVZs1FF+R/KPN3ZSQYYg=="], diff --git a/frontend/components/ui/model-selector.tsx b/frontend/components/ui/model-selector.tsx index 3449a9b3..87455b5f 100644 --- a/frontend/components/ui/model-selector.tsx +++ b/frontend/components/ui/model-selector.tsx @@ -58,8 +58,11 @@ export function ModelSelector({ if (onValueChange) { onValueChange(newValue); } + if (typeof window !== "undefined") { + window.localStorage.setItem("model", newValue); + } }; - + const selectedModelObj = getModelById(selectedModel); const getModelStatusIcon = (model: Model) => { diff --git a/frontend/components/ui/ui-input.tsx b/frontend/components/ui/ui-input.tsx index 458f5a15..04fe3378 100644 --- a/frontend/components/ui/ui-input.tsx +++ b/frontend/components/ui/ui-input.tsx @@ -18,8 +18,12 @@ import remarkGfm from "remark-gfm"; import { Geist_Mono } from "next/font/google"; import { cn } from "@/lib/utils"; import TabsSuggestion from "./tabs-suggestion"; -import { ModelSelector } from "@/components/ui/model-selector"; -import { DEFAULT_MODEL_ID } from "@/models/constants"; +import dynamic from "next/dynamic"; +const ModelSelectorNoSSR = dynamic( + () => import("@/components/ui/model-selector").then((m) => m.ModelSelector), + { ssr: false } +); +import { DEFAULT_MODEL_ID, getModelById } from "@/models/constants"; import { useTheme } from "next-themes"; import { ArrowUpIcon, WrapText } from "lucide-react"; import { atomOneDark } from "react-syntax-highlighter/dist/esm/styles/hljs"; @@ -54,7 +58,14 @@ interface UIInputProps { const UIInput = ({ conversationId: initialConversationId, }: UIInputProps = {}) => { - const [model, setModel] = useState(DEFAULT_MODEL_ID); + const [model, setModel] = useState(() => { + if (typeof window === "undefined") return DEFAULT_MODEL_ID; + const stored = window.localStorage.getItem("model"); + if (stored) { + return stored; + } + return DEFAULT_MODEL_ID; + }); const [query, setQuery] = useState(""); const [messages, setMessages] = useState([]); const [showWelcome, setShowWelcome] = useState(true); @@ -587,7 +598,7 @@ const UIInput = ({ />
-