mirror of
https://github.com/QwenLM/qwen-code.git
synced 2025-12-20 16:57:46 +00:00
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:
@@ -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();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user