mirror of
https://github.com/google-gemini/gemini-cli.git
synced 2026-05-13 21:32:56 -07:00
feat(vertex): add settings for Vertex AI request routing (#25513)
This commit is contained in:
@@ -836,12 +836,37 @@ describe('Server Config (config.ts)', () => {
|
||||
undefined,
|
||||
undefined,
|
||||
undefined,
|
||||
undefined,
|
||||
);
|
||||
// Verify that contentGeneratorConfig is updated
|
||||
expect(config.getContentGeneratorConfig()).toEqual(mockContentConfig);
|
||||
expect(GeminiClient).toHaveBeenCalledWith(config);
|
||||
});
|
||||
|
||||
it('should pass Vertex AI routing settings when refreshing auth', async () => {
|
||||
const vertexAiRouting = {
|
||||
requestType: 'shared' as const,
|
||||
sharedRequestType: 'priority' as const,
|
||||
};
|
||||
const config = new Config({
|
||||
...baseParams,
|
||||
vertexAiRouting,
|
||||
});
|
||||
|
||||
vi.mocked(createContentGeneratorConfig).mockResolvedValue({});
|
||||
|
||||
await config.refreshAuth(AuthType.USE_VERTEX_AI);
|
||||
|
||||
expect(createContentGeneratorConfig).toHaveBeenCalledWith(
|
||||
config,
|
||||
AuthType.USE_VERTEX_AI,
|
||||
undefined,
|
||||
undefined,
|
||||
undefined,
|
||||
vertexAiRouting,
|
||||
);
|
||||
});
|
||||
|
||||
it('should reset model availability status', async () => {
|
||||
const config = new Config(baseParams);
|
||||
const service = config.getModelAvailabilityService();
|
||||
|
||||
@@ -23,6 +23,7 @@ import {
|
||||
createContentGeneratorConfig,
|
||||
type ContentGenerator,
|
||||
type ContentGeneratorConfig,
|
||||
type VertexAiRoutingConfig,
|
||||
} from '../core/contentGenerator.js';
|
||||
import type { OverageStrategy } from '../billing/billing.js';
|
||||
import { PromptRegistry } from '../prompts/prompt-registry.js';
|
||||
@@ -731,6 +732,7 @@ export interface ConfigParameters {
|
||||
billing?: {
|
||||
overageStrategy?: OverageStrategy;
|
||||
};
|
||||
vertexAiRouting?: VertexAiRoutingConfig;
|
||||
}
|
||||
|
||||
export class Config implements McpContext, AgentLoopContext {
|
||||
@@ -936,6 +938,7 @@ export class Config implements McpContext, AgentLoopContext {
|
||||
private readonly billing: {
|
||||
overageStrategy: OverageStrategy;
|
||||
};
|
||||
private readonly vertexAiRouting: VertexAiRoutingConfig | undefined;
|
||||
|
||||
private readonly enableAgents: boolean;
|
||||
private agents: AgentSettings;
|
||||
@@ -1362,6 +1365,7 @@ export class Config implements McpContext, AgentLoopContext {
|
||||
this.billing = {
|
||||
overageStrategy: params.billing?.overageStrategy ?? 'ask',
|
||||
};
|
||||
this.vertexAiRouting = params.vertexAiRouting;
|
||||
|
||||
if (params.contextFileName) {
|
||||
setGeminiMdFilename(params.contextFileName);
|
||||
@@ -1549,6 +1553,7 @@ export class Config implements McpContext, AgentLoopContext {
|
||||
apiKey,
|
||||
baseUrl,
|
||||
customHeaders,
|
||||
this.vertexAiRouting,
|
||||
);
|
||||
this.contentGenerator = await createContentGenerator(
|
||||
newContentGeneratorConfig,
|
||||
|
||||
Reference in New Issue
Block a user