mirror of
https://github.com/lmstudio-ai/lms.git
synced 2025-09-19 12:54:19 +08:00
lms ls
This commit is contained in:
@ -1,8 +1,20 @@
|
||||
import { type SimpleLogger } from "@lmstudio/lms-common";
|
||||
import { LMStudioClient } from "@lmstudio/sdk";
|
||||
import { getServerLastStatus } from "./subcommands/server";
|
||||
|
||||
export function createClient(logger: SimpleLogger) {
|
||||
export async function createClient(logger: SimpleLogger) {
|
||||
let port: number;
|
||||
try {
|
||||
const lastStatus = await getServerLastStatus(logger);
|
||||
port = lastStatus.port;
|
||||
} catch (e) {
|
||||
logger.debug("Failed to get last server status", e);
|
||||
port = 1234;
|
||||
}
|
||||
const baseUrl = `ws://127.0.0.1:${port}`;
|
||||
logger.debug(`Connecting to server with baseUrl ${port}`);
|
||||
return new LMStudioClient({
|
||||
baseUrl,
|
||||
logger,
|
||||
});
|
||||
}
|
||||
|
Reference in New Issue
Block a user