Remove OpenClaw fallback compatibility
This commit is contained in:
@@ -31,23 +31,8 @@ type RunAiAnalysisOptions = GetAiConfigOptions & {
|
||||
generate?: (input: AiGenerateInput) => Promise<AiGenerateOutput>;
|
||||
};
|
||||
|
||||
const DEPRECATED_LEGACY_GATEWAY_ENV_KEYS = [
|
||||
'OPENCLAW_BASE_URL',
|
||||
'OPENCLAW_API_KEY',
|
||||
'OPENCLAW_MODEL',
|
||||
'OPENCLAW_AUTH_MODE',
|
||||
'OPENCLAW_BASIC_AUTH_USERNAME',
|
||||
'OPENCLAW_BASIC_AUTH_PASSWORD',
|
||||
'OPENCLAW_API_KEY_HEADER',
|
||||
'OPENCLAW_PORT',
|
||||
'OPENCLAW_IMAGE',
|
||||
'OPENCLAW_BUILD_CONTEXT',
|
||||
'OPENCLAW_DOCKERFILE'
|
||||
] as const;
|
||||
|
||||
const CODING_API_BASE_URL = 'https://api.z.ai/api/coding/paas/v4';
|
||||
|
||||
let warnedDeprecatedGatewayEnv = false;
|
||||
let warnedIgnoredZhipuBaseUrl = false;
|
||||
|
||||
function envValue(name: string, env: EnvSource = process.env) {
|
||||
@@ -69,22 +54,6 @@ function parseTemperature(value: string | undefined) {
|
||||
return Math.min(Math.max(parsed, 0), 2);
|
||||
}
|
||||
|
||||
function warnDeprecatedGatewayEnv(env: EnvSource, warn: (message: string) => void) {
|
||||
if (warnedDeprecatedGatewayEnv) {
|
||||
return;
|
||||
}
|
||||
|
||||
const presentKeys = DEPRECATED_LEGACY_GATEWAY_ENV_KEYS.filter((key) => Boolean(envValue(key, env)));
|
||||
if (presentKeys.length === 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
warnedDeprecatedGatewayEnv = true;
|
||||
warn(
|
||||
`[AI SDK] Deprecated OPENCLAW_* variables are ignored after migration: ${presentKeys.join(', ')}. Use ZHIPU_API_KEY, ZHIPU_MODEL, and AI_TEMPERATURE.`
|
||||
);
|
||||
}
|
||||
|
||||
function warnIgnoredZhipuBaseUrl(env: EnvSource, warn: (message: string) => void) {
|
||||
if (warnedIgnoredZhipuBaseUrl) {
|
||||
return;
|
||||
@@ -134,7 +103,6 @@ async function defaultGenerate(input: AiGenerateInput): Promise<AiGenerateOutput
|
||||
|
||||
export function getAiConfig(options?: GetAiConfigOptions) {
|
||||
const env = options?.env ?? process.env;
|
||||
warnDeprecatedGatewayEnv(env, options?.warn ?? console.warn);
|
||||
warnIgnoredZhipuBaseUrl(env, options?.warn ?? console.warn);
|
||||
|
||||
return {
|
||||
@@ -185,6 +153,5 @@ export async function runAiAnalysis(prompt: string, systemPrompt?: string, optio
|
||||
}
|
||||
|
||||
export function __resetAiWarningsForTests() {
|
||||
warnedDeprecatedGatewayEnv = false;
|
||||
warnedIgnoredZhipuBaseUrl = false;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user