Support single-model providers for workspace LLMs (#1179)

This commit is contained in:
Timothy Carambat 2024-04-23 13:18:28 -07:00 committed by GitHub
parent df17fbda36
commit 323c080b5e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 40 additions and 35 deletions

View File

@ -31,40 +31,36 @@ export default function GenericOpenAiOptions({ settings }) {
spellCheck={false} spellCheck={false}
/> />
</div> </div>
{!settings?.credentialsOnly && ( <div className="flex flex-col w-60">
<> <label className="text-white text-sm font-semibold block mb-4">
<div className="flex flex-col w-60"> Chat Model Name
<label className="text-white text-sm font-semibold block mb-4"> </label>
Chat Model Name <input
</label> type="text"
<input name="GenericOpenAiModelPref"
type="text" className="bg-zinc-900 text-white placeholder:text-white/20 text-sm rounded-lg focus:border-white block w-full p-2.5"
name="GenericOpenAiModelPref" placeholder="Model id used for chat requests"
className="bg-zinc-900 text-white placeholder:text-white/20 text-sm rounded-lg focus:border-white block w-full p-2.5" defaultValue={settings?.GenericOpenAiModelPref}
placeholder="Model id used for chat requests" required={true}
defaultValue={settings?.GenericOpenAiModelPref} autoComplete="off"
required={true} />
autoComplete="off" </div>
/> <div className="flex flex-col w-60">
</div> <label className="text-white text-sm font-semibold block mb-4">
<div className="flex flex-col w-60"> Token context window
<label className="text-white text-sm font-semibold block mb-4"> </label>
Token context window <input
</label> type="number"
<input name="GenericOpenAiTokenLimit"
type="number" className="bg-zinc-900 text-white placeholder:text-white/20 text-sm rounded-lg focus:border-white block w-full p-2.5"
name="GenericOpenAiTokenLimit" placeholder="Content window limit (eg: 4096)"
className="bg-zinc-900 text-white placeholder:text-white/20 text-sm rounded-lg focus:border-white block w-full p-2.5" min={1}
placeholder="Content window limit (eg: 4096)" onScroll={(e) => e.target.blur()}
min={1} defaultValue={settings?.GenericOpenAiTokenLimit}
onScroll={(e) => e.target.blur()} required={true}
defaultValue={settings?.GenericOpenAiTokenLimit} autoComplete="off"
required={true} />
autoComplete="off" </div>
/>
</div>
</>
)}
</div> </div>
); );
} }

View File

@ -159,6 +159,12 @@ export const AVAILABLE_LLM_PROVIDERS = [
options: (settings) => <GenericOpenAiOptions settings={settings} />, options: (settings) => <GenericOpenAiOptions settings={settings} />,
description: description:
"Connect to any OpenAi-compatible service via a custom configuration", "Connect to any OpenAi-compatible service via a custom configuration",
requiredConfig: [
"GenericOpenAiBasePath",
"GenericOpenAiModelPref",
"GenericOpenAiTokenLimit",
"GenericOpenAiKey",
],
}, },
{ {
name: "Native", name: "Native",

View File

@ -5,6 +5,9 @@ import { AVAILABLE_LLM_PROVIDERS } from "@/pages/GeneralSettings/LLMPreference";
import { CaretUpDown, MagnifyingGlass, X } from "@phosphor-icons/react"; import { CaretUpDown, MagnifyingGlass, X } from "@phosphor-icons/react";
import ChatModelSelection from "../ChatModelSelection"; import ChatModelSelection from "../ChatModelSelection";
// Some providers can only be associated with a single model.
// In that case there is no selection to be made so we can just move on.
const NO_MODEL_SELECTION = ["default", "huggingface", "generic-openai"];
const DISABLED_PROVIDERS = ["azure", "lmstudio", "native"]; const DISABLED_PROVIDERS = ["azure", "lmstudio", "native"];
const LLM_DEFAULT = { const LLM_DEFAULT = {
name: "System default", name: "System default",
@ -145,7 +148,7 @@ export default function WorkspaceLLMSelection({
</button> </button>
)} )}
</div> </div>
{selectedLLM !== "default" && ( {!NO_MODEL_SELECTION.includes(selectedLLM) && (
<div className="mt-4 flex flex-col gap-y-1"> <div className="mt-4 flex flex-col gap-y-1">
<ChatModelSelection <ChatModelSelection
provider={selectedLLM} provider={selectedLLM}