Refactor/standartize model providers, add "get provider key" for those who have it for first time users
Browse files- app/components/chat/APIKeyManager.tsx +4 -2
- app/components/chat/BaseChat.tsx +6 -15
- app/utils/constants.ts +124 -54
app/components/chat/APIKeyManager.tsx
CHANGED
|
@@ -1,8 +1,9 @@
|
|
| 1 |
import React, { useState } from 'react';
|
| 2 |
import { IconButton } from '~/components/ui/IconButton';
|
|
|
|
| 3 |
|
| 4 |
interface APIKeyManagerProps {
|
| 5 |
-
provider:
|
| 6 |
apiKey: string;
|
| 7 |
setApiKey: (key: string) => void;
|
| 8 |
}
|
|
@@ -18,7 +19,7 @@ export const APIKeyManager: React.FC<APIKeyManagerProps> = ({ provider, apiKey,
|
|
| 18 |
|
| 19 |
return (
|
| 20 |
<div className="flex items-center gap-2 mt-2 mb-2">
|
| 21 |
-
<span className="text-sm text-bolt-elements-textSecondary">{provider} API Key:</span>
|
| 22 |
{isEditing ? (
|
| 23 |
<>
|
| 24 |
<input
|
|
@@ -42,6 +43,7 @@ export const APIKeyManager: React.FC<APIKeyManagerProps> = ({ provider, apiKey,
|
|
| 42 |
<IconButton onClick={() => setIsEditing(true)} title="Edit API Key">
|
| 43 |
<div className="i-ph:pencil-simple" />
|
| 44 |
</IconButton>
|
|
|
|
| 45 |
</>
|
| 46 |
)}
|
| 47 |
</div>
|
|
|
|
| 1 |
import React, { useState } from 'react';
|
| 2 |
import { IconButton } from '~/components/ui/IconButton';
|
| 3 |
+
import type { ProviderInfo } from '~/utils/constants';
|
| 4 |
|
| 5 |
interface APIKeyManagerProps {
|
| 6 |
+
provider: ProviderInfo;
|
| 7 |
apiKey: string;
|
| 8 |
setApiKey: (key: string) => void;
|
| 9 |
}
|
|
|
|
| 19 |
|
| 20 |
return (
|
| 21 |
<div className="flex items-center gap-2 mt-2 mb-2">
|
| 22 |
+
<span className="text-sm text-bolt-elements-textSecondary">{provider?.name} API Key:</span>
|
| 23 |
{isEditing ? (
|
| 24 |
<>
|
| 25 |
<input
|
|
|
|
| 43 |
<IconButton onClick={() => setIsEditing(true)} title="Edit API Key">
|
| 44 |
<div className="i-ph:pencil-simple" />
|
| 45 |
</IconButton>
|
| 46 |
+
{!!provider?.getApiKeyLink ? <a href={provider?.getApiKeyLink}>{provider?.labelForGetApiKey || "Get API Key"}</a> : "" }
|
| 47 |
</>
|
| 48 |
)}
|
| 49 |
</div>
|
app/components/chat/BaseChat.tsx
CHANGED
|
@@ -7,7 +7,7 @@ import { Menu } from '~/components/sidebar/Menu.client';
|
|
| 7 |
import { IconButton } from '~/components/ui/IconButton';
|
| 8 |
import { Workbench } from '~/components/workbench/Workbench.client';
|
| 9 |
import { classNames } from '~/utils/classNames';
|
| 10 |
-
import { MODEL_LIST, DEFAULT_PROVIDER } from '~/utils/constants';
|
| 11 |
import { Messages } from './Messages.client';
|
| 12 |
import { SendButton } from './SendButton.client';
|
| 13 |
import { useState } from 'react';
|
|
@@ -24,12 +24,12 @@ const EXAMPLE_PROMPTS = [
|
|
| 24 |
{ text: 'How do I center a div?' },
|
| 25 |
];
|
| 26 |
|
| 27 |
-
const providerList =
|
| 28 |
|
| 29 |
const ModelSelector = ({ model, setModel, provider, setProvider, modelList, providerList }) => {
|
| 30 |
return (
|
| 31 |
<div className="mb-2 flex gap-2">
|
| 32 |
-
<select
|
| 33 |
value={provider}
|
| 34 |
onChange={(e) => {
|
| 35 |
setProvider(e.target.value);
|
|
@@ -39,19 +39,10 @@ const ModelSelector = ({ model, setModel, provider, setProvider, modelList, prov
|
|
| 39 |
className="flex-1 p-2 rounded-lg border border-bolt-elements-borderColor bg-bolt-elements-prompt-background text-bolt-elements-textPrimary focus:outline-none focus:ring-2 focus:ring-bolt-elements-focus transition-all"
|
| 40 |
>
|
| 41 |
{providerList.map((provider) => (
|
| 42 |
-
<option key={provider} value={provider}>
|
| 43 |
-
{provider}
|
| 44 |
</option>
|
| 45 |
))}
|
| 46 |
-
<option key="Ollama" value="Ollama">
|
| 47 |
-
Ollama
|
| 48 |
-
</option>
|
| 49 |
-
<option key="OpenAILike" value="OpenAILike">
|
| 50 |
-
OpenAILike
|
| 51 |
-
</option>
|
| 52 |
-
<option key="LMStudio" value="LMStudio">
|
| 53 |
-
LMStudio
|
| 54 |
-
</option>
|
| 55 |
</select>
|
| 56 |
<select
|
| 57 |
value={model}
|
|
@@ -315,4 +306,4 @@ export const BaseChat = React.forwardRef<HTMLDivElement, BaseChatProps>(
|
|
| 315 |
</div>
|
| 316 |
);
|
| 317 |
},
|
| 318 |
-
);
|
|
|
|
| 7 |
import { IconButton } from '~/components/ui/IconButton';
|
| 8 |
import { Workbench } from '~/components/workbench/Workbench.client';
|
| 9 |
import { classNames } from '~/utils/classNames';
|
| 10 |
+
import { MODEL_LIST, DEFAULT_PROVIDER, PROVIDER_LIST } from '~/utils/constants';
|
| 11 |
import { Messages } from './Messages.client';
|
| 12 |
import { SendButton } from './SendButton.client';
|
| 13 |
import { useState } from 'react';
|
|
|
|
| 24 |
{ text: 'How do I center a div?' },
|
| 25 |
];
|
| 26 |
|
| 27 |
+
const providerList = PROVIDER_LIST;
|
| 28 |
|
| 29 |
const ModelSelector = ({ model, setModel, provider, setProvider, modelList, providerList }) => {
|
| 30 |
return (
|
| 31 |
<div className="mb-2 flex gap-2">
|
| 32 |
+
<select
|
| 33 |
value={provider}
|
| 34 |
onChange={(e) => {
|
| 35 |
setProvider(e.target.value);
|
|
|
|
| 39 |
className="flex-1 p-2 rounded-lg border border-bolt-elements-borderColor bg-bolt-elements-prompt-background text-bolt-elements-textPrimary focus:outline-none focus:ring-2 focus:ring-bolt-elements-focus transition-all"
|
| 40 |
>
|
| 41 |
{providerList.map((provider) => (
|
| 42 |
+
<option key={provider.name} value={provider.name}>
|
| 43 |
+
{provider.name}
|
| 44 |
</option>
|
| 45 |
))}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 46 |
</select>
|
| 47 |
<select
|
| 48 |
value={model}
|
|
|
|
| 306 |
</div>
|
| 307 |
);
|
| 308 |
},
|
| 309 |
+
);
|
app/utils/constants.ts
CHANGED
|
@@ -8,48 +8,119 @@ export const PROVIDER_REGEX = /\[Provider: (.*?)\]\n\n/;
|
|
| 8 |
export const DEFAULT_MODEL = 'claude-3-5-sonnet-latest';
|
| 9 |
export const DEFAULT_PROVIDER = 'Anthropic';
|
| 10 |
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
{
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
|
| 28 |
-
|
| 29 |
-
{
|
| 30 |
-
|
| 31 |
-
|
| 32 |
-
|
| 33 |
-
|
| 34 |
-
|
| 35 |
-
|
| 36 |
-
|
| 37 |
-
|
| 38 |
-
|
| 39 |
-
|
| 40 |
-
|
| 41 |
-
|
| 42 |
-
|
| 43 |
-
|
| 44 |
-
|
| 45 |
-
|
| 46 |
-
|
| 47 |
-
|
| 48 |
-
|
| 49 |
-
|
| 50 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 51 |
];
|
| 52 |
|
|
|
|
|
|
|
|
|
|
| 53 |
export let MODEL_LIST: ModelInfo[] = [...staticModels];
|
| 54 |
|
| 55 |
const getOllamaBaseUrl = () => {
|
|
@@ -64,7 +135,7 @@ const getOllamaBaseUrl = () => {
|
|
| 64 |
const isDocker = process.env.RUNNING_IN_DOCKER === 'true';
|
| 65 |
|
| 66 |
return isDocker
|
| 67 |
-
? defaultBaseUrl.replace(
|
| 68 |
: defaultBaseUrl;
|
| 69 |
};
|
| 70 |
|
|
@@ -77,7 +148,7 @@ async function getOllamaModels(): Promise<ModelInfo[]> {
|
|
| 77 |
return data.models.map((model: OllamaModel) => ({
|
| 78 |
name: model.name,
|
| 79 |
label: `${model.name} (${model.details.parameter_size})`,
|
| 80 |
-
provider: 'Ollama'
|
| 81 |
}));
|
| 82 |
} catch (e) {
|
| 83 |
return [];
|
|
@@ -86,37 +157,37 @@ async function getOllamaModels(): Promise<ModelInfo[]> {
|
|
| 86 |
|
| 87 |
async function getOpenAILikeModels(): Promise<ModelInfo[]> {
|
| 88 |
try {
|
| 89 |
-
const base_url = import.meta.env.OPENAI_LIKE_API_BASE_URL ||
|
| 90 |
if (!base_url) {
|
| 91 |
return [];
|
| 92 |
}
|
| 93 |
-
const api_key = import.meta.env.OPENAI_LIKE_API_KEY ??
|
| 94 |
const response = await fetch(`${base_url}/models`, {
|
| 95 |
headers: {
|
| 96 |
-
Authorization: `Bearer ${api_key}
|
| 97 |
}
|
| 98 |
});
|
| 99 |
const res = await response.json() as any;
|
| 100 |
return res.data.map((model: any) => ({
|
| 101 |
name: model.id,
|
| 102 |
label: model.id,
|
| 103 |
-
provider: 'OpenAILike'
|
| 104 |
}));
|
| 105 |
} catch (e) {
|
| 106 |
-
return []
|
| 107 |
}
|
| 108 |
|
| 109 |
}
|
| 110 |
|
| 111 |
async function getLMStudioModels(): Promise<ModelInfo[]> {
|
| 112 |
try {
|
| 113 |
-
const base_url = import.meta.env.LMSTUDIO_API_BASE_URL ||
|
| 114 |
const response = await fetch(`${base_url}/v1/models`);
|
| 115 |
const data = await response.json() as any;
|
| 116 |
return data.data.map((model: any) => ({
|
| 117 |
name: model.id,
|
| 118 |
label: model.id,
|
| 119 |
-
provider: 'LMStudio'
|
| 120 |
}));
|
| 121 |
} catch (e) {
|
| 122 |
return [];
|
|
@@ -125,10 +196,9 @@ async function getLMStudioModels(): Promise<ModelInfo[]> {
|
|
| 125 |
|
| 126 |
|
| 127 |
async function initializeModelList(): Promise<void> {
|
| 128 |
-
|
| 129 |
-
|
| 130 |
-
const lmstudioModels = await getLMStudioModels();
|
| 131 |
-
MODEL_LIST = [...ollamaModels,...openAiLikeModels, ...staticModels,...lmstudioModels,];
|
| 132 |
}
|
|
|
|
| 133 |
initializeModelList().then();
|
| 134 |
-
export { getOllamaModels,getOpenAILikeModels,getLMStudioModels,initializeModelList };
|
|
|
|
| 8 |
export const DEFAULT_MODEL = 'claude-3-5-sonnet-latest';
|
| 9 |
export const DEFAULT_PROVIDER = 'Anthropic';
|
| 10 |
|
| 11 |
+
export type ProviderInfo = {
|
| 12 |
+
staticModels: ModelInfo[],
|
| 13 |
+
name: string,
|
| 14 |
+
getDynamicModels?: () => Promise<ModelInfo[]>,
|
| 15 |
+
getApiKeyLink?: string,
|
| 16 |
+
labelForGetApiKey?: string,
|
| 17 |
+
};
|
| 18 |
+
|
| 19 |
+
const PROVIDER_LIST: ProviderInfo[] = [
|
| 20 |
+
{
|
| 21 |
+
name: 'Ollama',
|
| 22 |
+
staticModels: [],
|
| 23 |
+
getDynamicModels: getOllamaModels
|
| 24 |
+
}, {
|
| 25 |
+
name: 'OpenAILike',
|
| 26 |
+
staticModels: [],
|
| 27 |
+
getDynamicModels: getOpenAILikeModels
|
| 28 |
+
},
|
| 29 |
+
{
|
| 30 |
+
name: 'OpenRouter',
|
| 31 |
+
staticModels: [
|
| 32 |
+
{ name: 'gpt-4o', label: 'GPT-4o', provider: 'OpenAI' },
|
| 33 |
+
{
|
| 34 |
+
name: 'anthropic/claude-3.5-sonnet',
|
| 35 |
+
label: 'Anthropic: Claude 3.5 Sonnet (OpenRouter)',
|
| 36 |
+
provider: 'OpenRouter'
|
| 37 |
+
},
|
| 38 |
+
{ name: 'anthropic/claude-3-haiku', label: 'Anthropic: Claude 3 Haiku (OpenRouter)', provider: 'OpenRouter' },
|
| 39 |
+
{ name: 'deepseek/deepseek-coder', label: 'Deepseek-Coder V2 236B (OpenRouter)', provider: 'OpenRouter' },
|
| 40 |
+
{ name: 'google/gemini-flash-1.5', label: 'Google Gemini Flash 1.5 (OpenRouter)', provider: 'OpenRouter' },
|
| 41 |
+
{ name: 'google/gemini-pro-1.5', label: 'Google Gemini Pro 1.5 (OpenRouter)', provider: 'OpenRouter' },
|
| 42 |
+
{ name: 'x-ai/grok-beta', label: 'xAI Grok Beta (OpenRouter)', provider: 'OpenRouter' },
|
| 43 |
+
{ name: 'mistralai/mistral-nemo', label: 'OpenRouter Mistral Nemo (OpenRouter)', provider: 'OpenRouter' },
|
| 44 |
+
{ name: 'qwen/qwen-110b-chat', label: 'OpenRouter Qwen 110b Chat (OpenRouter)', provider: 'OpenRouter' },
|
| 45 |
+
{ name: 'cohere/command', label: 'Cohere Command (OpenRouter)', provider: 'OpenRouter' }
|
| 46 |
+
],
|
| 47 |
+
getApiKeyLink: 'https://openrouter.ai/settings/keys'
|
| 48 |
+
}, {
|
| 49 |
+
name: 'Google',
|
| 50 |
+
staticModels: [
|
| 51 |
+
{ name: 'gemini-1.5-flash-latest', label: 'Gemini 1.5 Flash', provider: 'Google' },
|
| 52 |
+
{ name: 'gemini-1.5-pro-latest', label: 'Gemini 1.5 Pro', provider: 'Google' }
|
| 53 |
+
],
|
| 54 |
+
getApiKeyLink: 'https://aistudio.google.com/app/apikey'
|
| 55 |
+
}, {
|
| 56 |
+
name: 'Groq',
|
| 57 |
+
staticModels: [
|
| 58 |
+
{ name: 'llama-3.1-70b-versatile', label: 'Llama 3.1 70b (Groq)', provider: 'Groq' },
|
| 59 |
+
{ name: 'llama-3.1-8b-instant', label: 'Llama 3.1 8b (Groq)', provider: 'Groq' },
|
| 60 |
+
{ name: 'llama-3.2-11b-vision-preview', label: 'Llama 3.2 11b (Groq)', provider: 'Groq' },
|
| 61 |
+
{ name: 'llama-3.2-3b-preview', label: 'Llama 3.2 3b (Groq)', provider: 'Groq' },
|
| 62 |
+
{ name: 'llama-3.2-1b-preview', label: 'Llama 3.2 1b (Groq)', provider: 'Groq' }
|
| 63 |
+
],
|
| 64 |
+
getApiKeyLink: 'https://console.groq.com/keys'
|
| 65 |
+
}, {
|
| 66 |
+
name: 'Anthropic',
|
| 67 |
+
staticModels: [
|
| 68 |
+
{ name: 'claude-3-5-sonnet-latest', label: 'Claude 3.5 Sonnet (new)', provider: 'Anthropic' },
|
| 69 |
+
{ name: 'claude-3-5-sonnet-20240620', label: 'Claude 3.5 Sonnet (old)', provider: 'Anthropic' },
|
| 70 |
+
{ name: 'claude-3-5-haiku-latest', label: 'Claude 3.5 Haiku (new)', provider: 'Anthropic' },
|
| 71 |
+
{ name: 'claude-3-opus-latest', label: 'Claude 3 Opus', provider: 'Anthropic' },
|
| 72 |
+
{ name: 'claude-3-sonnet-20240229', label: 'Claude 3 Sonnet', provider: 'Anthropic' },
|
| 73 |
+
{ name: 'claude-3-haiku-20240307', label: 'Claude 3 Haiku', provider: 'Anthropic' }
|
| 74 |
+
],
|
| 75 |
+
getApiKeyLink: "https://console.anthropic.com/settings/keys",
|
| 76 |
+
}, {
|
| 77 |
+
name: 'OpenAI',
|
| 78 |
+
staticModels: [
|
| 79 |
+
{ name: 'gpt-4o-mini', label: 'GPT-4o Mini', provider: 'OpenAI' },
|
| 80 |
+
{ name: 'gpt-4-turbo', label: 'GPT-4 Turbo', provider: 'OpenAI' },
|
| 81 |
+
{ name: 'gpt-4', label: 'GPT-4', provider: 'OpenAI' },
|
| 82 |
+
{ name: 'gpt-3.5-turbo', label: 'GPT-3.5 Turbo', provider: 'OpenAI' }
|
| 83 |
+
],
|
| 84 |
+
getApiKeyLink: "https://platform.openai.com/api-keys",
|
| 85 |
+
}, {
|
| 86 |
+
name: 'xAI',
|
| 87 |
+
staticModels: [
|
| 88 |
+
{ name: 'grok-beta', label: 'xAI Grok Beta', provider: 'xAI' }
|
| 89 |
+
],
|
| 90 |
+
getApiKeyLink: 'https://docs.x.ai/docs/quickstart#creating-an-api-key'
|
| 91 |
+
}, {
|
| 92 |
+
name: 'Deepseek',
|
| 93 |
+
staticModels: [
|
| 94 |
+
{ name: 'deepseek-coder', label: 'Deepseek-Coder', provider: 'Deepseek' },
|
| 95 |
+
{ name: 'deepseek-chat', label: 'Deepseek-Chat', provider: 'Deepseek' }
|
| 96 |
+
],
|
| 97 |
+
getApiKeyLink: 'https://platform.deepseek.com/api_keys'
|
| 98 |
+
}, {
|
| 99 |
+
name: 'Mistral',
|
| 100 |
+
staticModels: [
|
| 101 |
+
{ name: 'open-mistral-7b', label: 'Mistral 7B', provider: 'Mistral' },
|
| 102 |
+
{ name: 'open-mixtral-8x7b', label: 'Mistral 8x7B', provider: 'Mistral' },
|
| 103 |
+
{ name: 'open-mixtral-8x22b', label: 'Mistral 8x22B', provider: 'Mistral' },
|
| 104 |
+
{ name: 'open-codestral-mamba', label: 'Codestral Mamba', provider: 'Mistral' },
|
| 105 |
+
{ name: 'open-mistral-nemo', label: 'Mistral Nemo', provider: 'Mistral' },
|
| 106 |
+
{ name: 'ministral-8b-latest', label: 'Mistral 8B', provider: 'Mistral' },
|
| 107 |
+
{ name: 'mistral-small-latest', label: 'Mistral Small', provider: 'Mistral' },
|
| 108 |
+
{ name: 'codestral-latest', label: 'Codestral', provider: 'Mistral' },
|
| 109 |
+
{ name: 'mistral-large-latest', label: 'Mistral Large Latest', provider: 'Mistral' }
|
| 110 |
+
],
|
| 111 |
+
getApiKeyLink: 'https://console.mistral.ai/api-keys/'
|
| 112 |
+
}, {
|
| 113 |
+
name: 'LMStudio',
|
| 114 |
+
staticModels: [],
|
| 115 |
+
getDynamicModels: getLMStudioModels,
|
| 116 |
+
getApiKeyLink: 'https://lmstudio.ai/',
|
| 117 |
+
labelForGetApiKey: 'Get LMStudio'
|
| 118 |
+
}
|
| 119 |
];
|
| 120 |
|
| 121 |
+
|
| 122 |
+
const staticModels: ModelInfo[] = PROVIDER_LIST.map(p => p.staticModels).flat();
|
| 123 |
+
|
| 124 |
export let MODEL_LIST: ModelInfo[] = [...staticModels];
|
| 125 |
|
| 126 |
const getOllamaBaseUrl = () => {
|
|
|
|
| 135 |
const isDocker = process.env.RUNNING_IN_DOCKER === 'true';
|
| 136 |
|
| 137 |
return isDocker
|
| 138 |
+
? defaultBaseUrl.replace('localhost', 'host.docker.internal')
|
| 139 |
: defaultBaseUrl;
|
| 140 |
};
|
| 141 |
|
|
|
|
| 148 |
return data.models.map((model: OllamaModel) => ({
|
| 149 |
name: model.name,
|
| 150 |
label: `${model.name} (${model.details.parameter_size})`,
|
| 151 |
+
provider: 'Ollama'
|
| 152 |
}));
|
| 153 |
} catch (e) {
|
| 154 |
return [];
|
|
|
|
| 157 |
|
| 158 |
async function getOpenAILikeModels(): Promise<ModelInfo[]> {
|
| 159 |
try {
|
| 160 |
+
const base_url = import.meta.env.OPENAI_LIKE_API_BASE_URL || '';
|
| 161 |
if (!base_url) {
|
| 162 |
return [];
|
| 163 |
}
|
| 164 |
+
const api_key = import.meta.env.OPENAI_LIKE_API_KEY ?? '';
|
| 165 |
const response = await fetch(`${base_url}/models`, {
|
| 166 |
headers: {
|
| 167 |
+
Authorization: `Bearer ${api_key}`
|
| 168 |
}
|
| 169 |
});
|
| 170 |
const res = await response.json() as any;
|
| 171 |
return res.data.map((model: any) => ({
|
| 172 |
name: model.id,
|
| 173 |
label: model.id,
|
| 174 |
+
provider: 'OpenAILike'
|
| 175 |
}));
|
| 176 |
} catch (e) {
|
| 177 |
+
return [];
|
| 178 |
}
|
| 179 |
|
| 180 |
}
|
| 181 |
|
| 182 |
async function getLMStudioModels(): Promise<ModelInfo[]> {
|
| 183 |
try {
|
| 184 |
+
const base_url = import.meta.env.LMSTUDIO_API_BASE_URL || 'http://localhost:1234';
|
| 185 |
const response = await fetch(`${base_url}/v1/models`);
|
| 186 |
const data = await response.json() as any;
|
| 187 |
return data.data.map((model: any) => ({
|
| 188 |
name: model.id,
|
| 189 |
label: model.id,
|
| 190 |
+
provider: 'LMStudio'
|
| 191 |
}));
|
| 192 |
} catch (e) {
|
| 193 |
return [];
|
|
|
|
| 196 |
|
| 197 |
|
| 198 |
async function initializeModelList(): Promise<void> {
|
| 199 |
+
MODEL_LIST = [...(await Promise.all(
|
| 200 |
+
PROVIDER_LIST.filter(p => !!p.getDynamicModels).map(p => p.getDynamicModels()))).flat(), ...staticModels];
|
|
|
|
|
|
|
| 201 |
}
|
| 202 |
+
|
| 203 |
initializeModelList().then();
|
| 204 |
+
export { getOllamaModels, getOpenAILikeModels, getLMStudioModels, initializeModelList, PROVIDER_LIST };
|