mirror of
https://github.com/QwenLM/qwen-code.git
synced 2025-12-19 09:33:53 +00:00
@@ -26,6 +26,10 @@ import {
|
|||||||
logApiResponse,
|
logApiResponse,
|
||||||
logApiError,
|
logApiError,
|
||||||
} from '../telemetry/loggers.js';
|
} from '../telemetry/loggers.js';
|
||||||
|
import {
|
||||||
|
getStructuredResponse,
|
||||||
|
getStructuredResponseFromParts,
|
||||||
|
} from '../utils/generateContentResponseUtilities.js';
|
||||||
import {
|
import {
|
||||||
ApiErrorEvent,
|
ApiErrorEvent,
|
||||||
ApiRequestEvent,
|
ApiRequestEvent,
|
||||||
@@ -138,7 +142,11 @@ export class GeminiChat {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private _getRequestTextFromContents(contents: Content[]): string {
|
private _getRequestTextFromContents(contents: Content[]): string {
|
||||||
return JSON.stringify(contents);
|
return contents
|
||||||
|
.flatMap((content) => content.parts ?? [])
|
||||||
|
.map((part) => part.text)
|
||||||
|
.filter(Boolean)
|
||||||
|
.join('');
|
||||||
}
|
}
|
||||||
|
|
||||||
private async _logApiRequest(
|
private async _logApiRequest(
|
||||||
@@ -310,7 +318,7 @@ export class GeminiChat {
|
|||||||
durationMs,
|
durationMs,
|
||||||
prompt_id,
|
prompt_id,
|
||||||
response.usageMetadata,
|
response.usageMetadata,
|
||||||
JSON.stringify(response),
|
getStructuredResponse(response),
|
||||||
);
|
);
|
||||||
|
|
||||||
this.sendPromise = (async () => {
|
this.sendPromise = (async () => {
|
||||||
@@ -546,12 +554,12 @@ export class GeminiChat {
|
|||||||
allParts.push(...content.parts);
|
allParts.push(...content.parts);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
const fullText = getStructuredResponseFromParts(allParts);
|
||||||
await this._logApiResponse(
|
await this._logApiResponse(
|
||||||
durationMs,
|
durationMs,
|
||||||
prompt_id,
|
prompt_id,
|
||||||
this.getFinalUsageMetadata(chunks),
|
this.getFinalUsageMetadata(chunks),
|
||||||
JSON.stringify(chunks),
|
fullText,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
this.recordHistory(inputContent, outputContent);
|
this.recordHistory(inputContent, outputContent);
|
||||||
|
|||||||
Reference in New Issue
Block a user