mirror of
https://github.com/google-gemini/gemini-cli.git
synced 2026-02-01 14:44:29 +00:00
feat(core): enable overriding CODE_ASSIST_API_VERSION with env var (#17942)
Co-authored-by: Charlotte Lin <charlotteclin@google.com>
This commit is contained in:
@@ -327,6 +327,22 @@ describe('CodeAssistServer', () => {
|
||||
const url = server.getMethodUrl('testMethod');
|
||||
expect(url).toBe('https://custom-endpoint.com/v1internal:testMethod');
|
||||
});
|
||||
|
||||
it('should use the CODE_ASSIST_API_VERSION environment variable if set', () => {
|
||||
process.env['CODE_ASSIST_API_VERSION'] = 'v2beta';
|
||||
const server = new CodeAssistServer({} as never);
|
||||
const url = server.getMethodUrl('testMethod');
|
||||
expect(url).toBe('https://cloudcode-pa.googleapis.com/v2beta:testMethod');
|
||||
});
|
||||
|
||||
it('should use default value if CODE_ASSIST_API_VERSION env var is empty', () => {
|
||||
process.env['CODE_ASSIST_API_VERSION'] = '';
|
||||
const server = new CodeAssistServer({} as never);
|
||||
const url = server.getMethodUrl('testMethod');
|
||||
expect(url).toBe(
|
||||
'https://cloudcode-pa.googleapis.com/v1internal:testMethod',
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
it('should call the generateContentStream endpoint and parse SSE', async () => {
|
||||
|
||||
@@ -374,7 +374,9 @@ export class CodeAssistServer implements ContentGenerator {
|
||||
private getBaseUrl(): string {
|
||||
const endpoint =
|
||||
process.env['CODE_ASSIST_ENDPOINT'] ?? CODE_ASSIST_ENDPOINT;
|
||||
return `${endpoint}/${CODE_ASSIST_API_VERSION}`;
|
||||
const version =
|
||||
process.env['CODE_ASSIST_API_VERSION'] || CODE_ASSIST_API_VERSION;
|
||||
return `${endpoint}/${version}`;
|
||||
}
|
||||
|
||||
getMethodUrl(method: string): string {
|
||||
|
||||
Reference in New Issue
Block a user