LM studio e2e test (#297)
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import { ipcMain } from "electron";
|
||||
import log from "electron-log";
|
||||
import type { LocalModelListResponse, LocalModel } from "../ipc_types";
|
||||
import { LM_STUDIO_BASE_URL } from "../utils/lm_studio_utils";
|
||||
|
||||
const logger = log.scope("lmstudio_handler");
|
||||
|
||||
@@ -19,7 +20,7 @@ export interface LMStudioModel {
|
||||
|
||||
export async function fetchLMStudioModels(): Promise<LocalModelListResponse> {
|
||||
const modelsResponse: Response = await fetch(
|
||||
"http://localhost:1234/api/v0/models",
|
||||
`${LM_STUDIO_BASE_URL}/api/v0/models`,
|
||||
);
|
||||
if (!modelsResponse.ok) {
|
||||
throw new Error("Failed to fetch models from LM Studio");
|
||||
|
||||
@@ -13,6 +13,7 @@ import { LanguageModelProvider } from "../ipc_types";
|
||||
import { llmErrorStore } from "@/main/llm_error_store";
|
||||
import { createDyadEngine } from "./llm_engine_provider";
|
||||
import { findLanguageModel } from "./findLanguageModel";
|
||||
import { LM_STUDIO_BASE_URL } from "./lm_studio_utils";
|
||||
|
||||
const dyadLocalEngine = process.env.DYAD_LOCAL_ENGINE;
|
||||
const dyadGatewayUrl = process.env.DYAD_GATEWAY_URL;
|
||||
@@ -257,7 +258,7 @@ function getRegularModelClient(
|
||||
}
|
||||
case "lmstudio": {
|
||||
// LM Studio uses OpenAI compatible API
|
||||
const baseURL = providerConfig.apiBaseUrl || "http://localhost:1234/v1";
|
||||
const baseURL = providerConfig.apiBaseUrl || LM_STUDIO_BASE_URL + "/v1";
|
||||
const provider = createOpenAICompatible({
|
||||
name: "lmstudio",
|
||||
baseURL,
|
||||
|
||||
2
src/ipc/utils/lm_studio_utils.ts
Normal file
2
src/ipc/utils/lm_studio_utils.ts
Normal file
@@ -0,0 +1,2 @@
|
||||
export const LM_STUDIO_BASE_URL =
|
||||
process.env.LM_STUDIO_BASE_URL_FOR_TESTING || "http://localhost:1234";
|
||||
Reference in New Issue
Block a user