mirror of
https://github.com/QwenLM/qwen-code.git
synced 2025-12-20 16:57:46 +00:00
Simplify user agent handling. (#828)
This commit is contained in:
committed by
GitHub
parent
87474e52d7
commit
0613062fc8
@@ -46,7 +46,6 @@ describe('Server Config (config.ts)', () => {
|
||||
const DEBUG_MODE = false;
|
||||
const QUESTION = 'test question';
|
||||
const FULL_CONTEXT = false;
|
||||
const USER_AGENT = 'ServerTestAgent/1.0';
|
||||
const USER_MEMORY = 'Test User Memory';
|
||||
const TELEMETRY = false;
|
||||
const EMBEDDING_MODEL = 'gemini-embedding';
|
||||
@@ -54,7 +53,6 @@ describe('Server Config (config.ts)', () => {
|
||||
contentGeneratorConfig: {
|
||||
apiKey: API_KEY,
|
||||
model: MODEL,
|
||||
userAgent: USER_AGENT,
|
||||
},
|
||||
embeddingModel: EMBEDDING_MODEL,
|
||||
sandbox: SANDBOX,
|
||||
|
||||
@@ -35,18 +35,18 @@ export type ContentGeneratorConfig = {
|
||||
model: string;
|
||||
apiKey?: string;
|
||||
vertexai?: boolean;
|
||||
userAgent: string;
|
||||
};
|
||||
|
||||
export function createContentGenerator(
|
||||
config: ContentGeneratorConfig,
|
||||
): ContentGenerator {
|
||||
const version = process.env.CLI_VERSION || process.version;
|
||||
const googleGenAI = new GoogleGenAI({
|
||||
apiKey: config.apiKey === '' ? undefined : config.apiKey,
|
||||
vertexai: config.vertexai,
|
||||
httpOptions: {
|
||||
headers: {
|
||||
'User-Agent': config.userAgent,
|
||||
'User-Agent': `GeminiCLI/${version}/(${process.platform}; ${process.arch})`,
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
@@ -64,10 +64,9 @@ export function initializeTelemetry(config: Config): void {
|
||||
return;
|
||||
}
|
||||
|
||||
const geminiCliVersion = config.getContentGeneratorConfig().userAgent;
|
||||
const resource = new Resource({
|
||||
[SemanticResourceAttributes.SERVICE_NAME]: SERVICE_NAME,
|
||||
[SemanticResourceAttributes.SERVICE_VERSION]: geminiCliVersion,
|
||||
[SemanticResourceAttributes.SERVICE_VERSION]: process.version,
|
||||
'session.id': sessionId,
|
||||
});
|
||||
|
||||
|
||||
@@ -128,7 +128,6 @@ const baseConfigParams: ConfigParameters = {
|
||||
model: 'test-model',
|
||||
apiKey: 'test-api-key',
|
||||
vertexai: false,
|
||||
userAgent: 'TestAgent/1.0',
|
||||
},
|
||||
embeddingModel: 'test-embedding-model',
|
||||
sandbox: false,
|
||||
|
||||
Reference in New Issue
Block a user