mirror of https://github.com/openclaw/openclaw.git
48 lines
1.5 KiB
TypeScript
48 lines
1.5 KiB
TypeScript
import {
|
|
createDefaultModelPresetAppliers,
|
|
type OpenClawConfig,
|
|
} from "openclaw/plugin-sdk/provider-onboard";
|
|
import {
|
|
buildMoonshotProvider,
|
|
MOONSHOT_BASE_URL,
|
|
MOONSHOT_DEFAULT_MODEL_ID,
|
|
} from "./provider-catalog.js";
|
|
|
|
export const MOONSHOT_CN_BASE_URL = "https://api.moonshot.cn/v1";
|
|
export const MOONSHOT_DEFAULT_MODEL_REF = `moonshot/${MOONSHOT_DEFAULT_MODEL_ID}`;
|
|
|
|
const moonshotPresetAppliers = createDefaultModelPresetAppliers<[string]>({
|
|
primaryModelRef: MOONSHOT_DEFAULT_MODEL_REF,
|
|
resolveParams: (_cfg: OpenClawConfig, baseUrl: string) => {
|
|
const defaultModel = buildMoonshotProvider().models[0];
|
|
if (!defaultModel) {
|
|
return null;
|
|
}
|
|
|
|
return {
|
|
providerId: "moonshot",
|
|
api: "openai-completions",
|
|
baseUrl,
|
|
defaultModel,
|
|
defaultModelId: MOONSHOT_DEFAULT_MODEL_ID,
|
|
aliases: [{ modelRef: MOONSHOT_DEFAULT_MODEL_REF, alias: "Kimi" }],
|
|
};
|
|
},
|
|
});
|
|
|
|
export function applyMoonshotProviderConfig(cfg: OpenClawConfig): OpenClawConfig {
|
|
return moonshotPresetAppliers.applyProviderConfig(cfg, MOONSHOT_BASE_URL);
|
|
}
|
|
|
|
export function applyMoonshotProviderConfigCn(cfg: OpenClawConfig): OpenClawConfig {
|
|
return moonshotPresetAppliers.applyProviderConfig(cfg, MOONSHOT_CN_BASE_URL);
|
|
}
|
|
|
|
export function applyMoonshotConfig(cfg: OpenClawConfig): OpenClawConfig {
|
|
return moonshotPresetAppliers.applyConfig(cfg, MOONSHOT_BASE_URL);
|
|
}
|
|
|
|
export function applyMoonshotConfigCn(cfg: OpenClawConfig): OpenClawConfig {
|
|
return moonshotPresetAppliers.applyConfig(cfg, MOONSHOT_CN_BASE_URL);
|
|
}
|