Skip to content

UX: Support quick addition of models. #1472

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 11 additions & 3 deletions src/components/ui/password-input.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import React, { useEffect, useRef, useState } from "react";
import React, { useEffect, useRef, useState, useMemo } from "react";
import { Input } from "@/components/ui/input";
import { cn } from "@/lib/utils";
import { Eye, EyeOff } from "lucide-react";
import { getDecryptedKey } from "@/encryptionService";
import { logError } from "@/logger";
import { err2String } from "@/utils";
import { err2String, debounce } from "@/utils";

export function PasswordInput({
value,
Expand All @@ -23,6 +23,14 @@ export function PasswordInput({
const inputRef = useRef<HTMLInputElement>(null);
const isFirstLoad = useRef(true);

// Add debounced onChange function
const debouncedOnChange = useMemo(() => {
if (!onChange) return;
return debounce((value: string) => {
onChange(value);
}, 300);
}, [onChange]);

// Initialize the input value on first load
useEffect(() => {
const processValue = async () => {
Expand All @@ -49,7 +57,7 @@ export function PasswordInput({
<Input
ref={inputRef}
type={showPassword ? "text" : "password"}
onChange={(e) => onChange?.(e.target.value)}
onChange={(e) => debouncedOnChange?.(e.target.value)}
placeholder={placeholder}
disabled={disabled}
className={cn("![padding-right:1.75rem] w-full")}
Expand Down
16 changes: 16 additions & 0 deletions src/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -320,6 +320,7 @@ export interface ProviderMetadata {
label: string;
host: string;
keyManagementURL: string;
listModelURL: string;
testModel?: ChatModels;
}

Expand All @@ -329,86 +330,101 @@ export const ProviderInfo: Record<Provider, ProviderMetadata> = {
label: "OpenAI",
host: "https://api.openai.com",
keyManagementURL: "https://platform.openai.com/api-keys",
listModelURL: "https://api.openai.com/v1/models",
testModel: ChatModels.GPT_41,
},
[ChatModelProviders.AZURE_OPENAI]: {
label: "Azure OpenAI",
host: "",
keyManagementURL: "",
listModelURL: "",
testModel: ChatModels.AZURE_OPENAI,
},
[ChatModelProviders.ANTHROPIC]: {
label: "Anthropic",
host: "https://api.anthropic.com/",
keyManagementURL: "https://console.anthropic.com/settings/keys",
listModelURL: "https://api.anthropic.com/v1/models",
testModel: ChatModels.CLAUDE_3_5_SONNET,
},
[ChatModelProviders.COHEREAI]: {
label: "Cohere",
host: "https://api.cohere.com",
keyManagementURL: "https://dashboard.cohere.ai/api-keys",
listModelURL: "https://api.cohere.com/v1/models",
testModel: ChatModels.COMMAND_R,
},
[ChatModelProviders.GOOGLE]: {
label: "Gemini",
host: "https://generativelanguage.googleapis.com",
keyManagementURL: "https://makersuite.google.com/app/apikey",
listModelURL: "https://generativelanguage.googleapis.com/v1beta/models",
testModel: ChatModels.GEMINI_FLASH,
},
[ChatModelProviders.XAI]: {
label: "XAI",
host: "https://api.x.ai/v1",
keyManagementURL: "https://console.x.ai",
listModelURL: "https://api.x.ai/v1/models",
testModel: ChatModels.GROK3,
},
[ChatModelProviders.OPENROUTERAI]: {
label: "OpenRouter",
host: "https://openrouter.ai/api/v1/",
keyManagementURL: "https://openrouter.ai/keys",
listModelURL: "https://openrouter.ai/api/v1/models",
testModel: ChatModels.OPENROUTER_GPT_4o,
},
[ChatModelProviders.GROQ]: {
label: "Groq",
host: "https://api.groq.com/openai",
keyManagementURL: "https://console.groq.com/keys",
listModelURL: "https://api.groq.com/openai/v1/models",
testModel: ChatModels.GROQ_LLAMA_8b,
},
[ChatModelProviders.OLLAMA]: {
label: "Ollama",
host: "http://localhost:11434/v1/",
keyManagementURL: "",
listModelURL: "",
},
[ChatModelProviders.LM_STUDIO]: {
label: "LM Studio",
host: "http://localhost:1234/v1",
keyManagementURL: "",
listModelURL: "",
},
[ChatModelProviders.OPENAI_FORMAT]: {
label: "OpenAI Format",
host: "https://api.example.com/v1",
keyManagementURL: "",
listModelURL: "",
},
[ChatModelProviders.MISTRAL]: {
label: "Mistral",
host: "https://api.mistral.ai/v1",
keyManagementURL: "https://console.mistral.ai/api-keys",
listModelURL: "https://api.mistral.ai/v1/models",
testModel: ChatModels.MISTRAL_TINY,
},
[ChatModelProviders.DEEPSEEK]: {
label: "DeepSeek",
host: "https://api.deepseek.com/",
keyManagementURL: "https://platform.deepseek.com/api-keys",
listModelURL: "https://api.deepseek.com/models",
testModel: ChatModels.DEEPSEEK_CHAT,
},
[EmbeddingModelProviders.COPILOT_PLUS]: {
label: "Copilot Plus",
host: "https://api.brevilabs.com/v1",
keyManagementURL: "",
listModelURL: "",
},
[EmbeddingModelProviders.COPILOT_PLUS_JINA]: {
label: "Copilot Plus",
host: "https://api.brevilabs.com/v1",
keyManagementURL: "",
listModelURL: "",
},
};

Expand Down
Loading