mirror of
https://github.com/QwenLM/qwen-code.git
synced 2025-12-19 09:33:53 +00:00
Log all parts of a streaming response (#6855)
This commit is contained in:
@@ -149,9 +149,12 @@ export class LoggingContentGenerator implements ContentGenerator {
|
||||
userPromptId: string,
|
||||
): AsyncGenerator<GenerateContentResponse> {
|
||||
let lastResponse: GenerateContentResponse | undefined;
|
||||
const responses: GenerateContentResponse[] = [];
|
||||
|
||||
let lastUsageMetadata: GenerateContentResponseUsageMetadata | undefined;
|
||||
try {
|
||||
for await (const response of stream) {
|
||||
responses.push(response);
|
||||
lastResponse = response;
|
||||
if (response.usageMetadata) {
|
||||
lastUsageMetadata = response.usageMetadata;
|
||||
@@ -169,7 +172,7 @@ export class LoggingContentGenerator implements ContentGenerator {
|
||||
durationMs,
|
||||
userPromptId,
|
||||
lastUsageMetadata,
|
||||
JSON.stringify(lastResponse),
|
||||
JSON.stringify(responses),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user