mirror of
https://github.com/openclaw/openclaw.git
synced 2026-04-19 21:21:10 +00:00
47 lines
1.4 KiB
TypeScript
47 lines
1.4 KiB
TypeScript
import type { OpenClawConfig } from "../config/config.js";
|
|
import { resolveProviderBuiltInModelSuppression } from "../plugins/provider-runtime.js";
|
|
import { normalizeLowercaseStringOrEmpty } from "../shared/string-coerce.js";
|
|
import { normalizeProviderId } from "./provider-id.js";
|
|
|
|
function resolveBuiltInModelSuppression(params: {
|
|
provider?: string | null;
|
|
id?: string | null;
|
|
baseUrl?: string | null;
|
|
config?: OpenClawConfig;
|
|
}) {
|
|
const provider = normalizeProviderId(params.provider ?? "");
|
|
const modelId = normalizeLowercaseStringOrEmpty(params.id);
|
|
if (!provider || !modelId) {
|
|
return undefined;
|
|
}
|
|
return resolveProviderBuiltInModelSuppression({
|
|
...(params.config ? { config: params.config } : {}),
|
|
env: process.env,
|
|
context: {
|
|
...(params.config ? { config: params.config } : {}),
|
|
env: process.env,
|
|
provider,
|
|
modelId,
|
|
...(params.baseUrl ? { baseUrl: params.baseUrl } : {}),
|
|
},
|
|
});
|
|
}
|
|
|
|
export function shouldSuppressBuiltInModel(params: {
|
|
provider?: string | null;
|
|
id?: string | null;
|
|
baseUrl?: string | null;
|
|
config?: OpenClawConfig;
|
|
}) {
|
|
return resolveBuiltInModelSuppression(params)?.suppress ?? false;
|
|
}
|
|
|
|
export function buildSuppressedBuiltInModelError(params: {
|
|
provider?: string | null;
|
|
id?: string | null;
|
|
baseUrl?: string | null;
|
|
config?: OpenClawConfig;
|
|
}): string | undefined {
|
|
return resolveBuiltInModelSuppression(params)?.errorMessage;
|
|
}
|