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