Auth First Run (#1207)

Co-authored-by: Tommaso Sciortino <sciortino@gmail.com>
Co-authored-by: N. Taylor Mullen <ntaylormullen@google.com>
This commit is contained in:
matt korwel
2025-06-19 16:52:22 -07:00
committed by GitHub
parent c48fcaa8c3
commit 04518b52c0
37 changed files with 636 additions and 349 deletions

View File

@@ -33,6 +33,7 @@ import { getErrorMessage } from '../utils/errors.js';
import { tokenLimit } from './tokenLimits.js';
import {
ContentGenerator,
ContentGeneratorConfig,
createContentGenerator,
} from './contentGenerator.js';
import { ProxyAgent, setGlobalDispatcher } from 'undici';
@@ -63,12 +64,18 @@ export class GeminiClient {
this.embeddingModel = config.getEmbeddingModel();
}
async initialize() {
async initialize(contentGeneratorConfig: ContentGeneratorConfig) {
this.contentGenerator = await createContentGenerator(
this.config.getContentGeneratorConfig(),
contentGeneratorConfig,
);
this.chat = await this.startChat();
}
private getContentGenerator(): ContentGenerator {
if (!this.contentGenerator) {
throw new Error('Content generator not initialized');
}
return this.contentGenerator;
}
async addHistory(content: Content) {
this.getChat().addHistory(content);
@@ -81,13 +88,6 @@ export class GeminiClient {
return this.chat;
}
private getContentGenerator(): ContentGenerator {
if (!this.contentGenerator) {
throw new Error('Content generator not initialized');
}
return this.contentGenerator;
}
async getHistory(): Promise<Content[]> {
return this.getChat().getHistory();
}