GigaChat: honor implicit base URLs
This commit is contained in:
parent
181031856d
commit
5df5f68241
@ -109,6 +109,7 @@ export const MODELS_CONFIG_IMPLICIT_ENV_VARS = [
|
||||
"VOLCANO_ENGINE_API_KEY",
|
||||
"BYTEPLUS_API_KEY",
|
||||
"GIGACHAT_CREDENTIALS",
|
||||
"GIGACHAT_BASE_URL",
|
||||
"KILOCODE_API_KEY",
|
||||
"KIMI_API_KEY",
|
||||
"KIMICODE_API_KEY",
|
||||
|
||||
@ -20,4 +20,21 @@ describe("GigaChat implicit provider", () => {
|
||||
expect(providers?.gigachat?.models?.map((model) => model.id)).toEqual(["GigaChat-2-Max"]);
|
||||
});
|
||||
});
|
||||
|
||||
it("honors GIGACHAT_BASE_URL for implicit providers", async () => {
|
||||
const agentDir = mkdtempSync(join(tmpdir(), "openclaw-test-"));
|
||||
|
||||
await withEnvAsync(
|
||||
{
|
||||
GIGACHAT_CREDENTIALS: "user:password",
|
||||
GIGACHAT_BASE_URL: "https://preview.gigachat.example/api/v1",
|
||||
},
|
||||
async () => {
|
||||
const providers = await resolveImplicitProvidersForTest({ agentDir });
|
||||
|
||||
expect(providers?.gigachat?.baseUrl).toBe("https://preview.gigachat.example/api/v1");
|
||||
expect(providers?.gigachat?.apiKey).toBe("GIGACHAT_CREDENTIALS");
|
||||
},
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
@ -88,11 +88,11 @@ function normalizeProviderBaseUrl(baseUrl: string | undefined): string {
|
||||
}
|
||||
}
|
||||
|
||||
function buildGigachatProvider(apiKey?: string): ProviderConfig {
|
||||
function buildGigachatProvider(params: { apiKey?: string; baseUrl?: string }): ProviderConfig {
|
||||
return {
|
||||
baseUrl: GIGACHAT_BASE_URL,
|
||||
baseUrl: params.baseUrl?.trim() || GIGACHAT_BASE_URL,
|
||||
api: "openai-completions",
|
||||
...(apiKey ? { apiKey } : {}),
|
||||
...(params.apiKey ? { apiKey: params.apiKey } : {}),
|
||||
models: [buildGigachatModelDefinition()],
|
||||
} satisfies ProviderConfig;
|
||||
}
|
||||
@ -713,7 +713,10 @@ function resolveImplicitGigachatProvider(ctx: ImplicitProviderContext): Provider
|
||||
return null;
|
||||
}
|
||||
|
||||
return buildGigachatProvider(auth.apiKey);
|
||||
return buildGigachatProvider({
|
||||
apiKey: auth.apiKey,
|
||||
baseUrl: ctx.env.GIGACHAT_BASE_URL,
|
||||
});
|
||||
}
|
||||
|
||||
export async function resolveImplicitProviders(
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user