LM Studio Integration

This commit is contained in:
Karrot0
2024-10-27 23:16:07 -04:00
parent 8e7220e8fb
commit 4edcc5e331
8 changed files with 23494 additions and 5 deletions

View File

@@ -86,10 +86,28 @@ async function getOpenAILikeModels(): Promise<ModelInfo[]> {
}
}
async function getLMStudioModels(): Promise<ModelInfo[]> {
try {
const base_url = import.meta.env.LMSTUDIO_API_BASE_URL || "http://localhost:1234";
const response = await fetch(`${base_url}/v1/models`);
const data = await response.json() as any;
return data.data.map((model: any) => ({
name: model.id,
label: model.id,
provider: 'LMStudio',
}));
} catch (e) {
return [];
}
}
async function initializeModelList(): Promise<void> {
const ollamaModels = await getOllamaModels();
const openAiLikeModels = await getOpenAILikeModels();
MODEL_LIST = [...ollamaModels,...openAiLikeModels, ...staticModels];
const lmstudioModels = await getLMStudioModels();
MODEL_LIST = [...ollamaModels,...openAiLikeModels, ...staticModels,...lmstudioModels,];
}
initializeModelList().then();
export { getOllamaModels, getOpenAILikeModels, initializeModelList };
export { getOllamaModels,getOpenAILikeModels,getLMStudioModels,initializeModelList };