mirror of
https://github.com/openclaw/openclaw.git
synced 2026-03-29 19:01:44 +00:00
24 lines
805 B
TypeScript
24 lines
805 B
TypeScript
import type { OpenClawConfig } from "openclaw/plugin-sdk/config-runtime";
|
|
import { discoverOpenAICompatibleLocalModels } from "openclaw/plugin-sdk/provider-setup";
|
|
import { SGLANG_DEFAULT_BASE_URL, SGLANG_PROVIDER_LABEL } from "./defaults.js";
|
|
|
|
type ModelsConfig = NonNullable<OpenClawConfig["models"]>;
|
|
type ProviderConfig = NonNullable<ModelsConfig["providers"]>[string];
|
|
|
|
export async function buildSglangProvider(params?: {
|
|
baseUrl?: string;
|
|
apiKey?: string;
|
|
}): Promise<ProviderConfig> {
|
|
const baseUrl = (params?.baseUrl?.trim() || SGLANG_DEFAULT_BASE_URL).replace(/\/+$/, "");
|
|
const models = await discoverOpenAICompatibleLocalModels({
|
|
baseUrl,
|
|
apiKey: params?.apiKey,
|
|
label: SGLANG_PROVIDER_LABEL,
|
|
});
|
|
return {
|
|
baseUrl,
|
|
api: "openai-completions",
|
|
models,
|
|
};
|
|
}
|