diff options
| author | Anjali Sridhar <[email protected]> | 2025-07-23 06:51:40 -0700 |
|---|---|---|
| committer | Anjali Sridhar <[email protected]> | 2025-07-23 06:51:40 -0700 |
| commit | 2d1eafae95b7a140ac42ea5899f2f4ff6bca80ae (patch) | |
| tree | 57e2e536fffc4fc7aad93880aafd3a7c1cf0fa85 /packages/core/src | |
| parent | 1de246236b04f2faf7e0222921568a193a35a275 (diff) | |
Revert "wip"
This reverts commit 1de246236b04f2faf7e0222921568a193a35a275.
Diffstat (limited to 'packages/core/src')
| -rw-r--r-- | packages/core/src/core/geminiChat.ts | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/packages/core/src/core/geminiChat.ts b/packages/core/src/core/geminiChat.ts index 5e0a62c0..d1a7bdec 100644 --- a/packages/core/src/core/geminiChat.ts +++ b/packages/core/src/core/geminiChat.ts @@ -27,6 +27,10 @@ import { logApiError, } from '../telemetry/loggers.js'; import { + getStructuredResponse, + getStructuredResponseFromParts, +} from '../utils/generateContentResponseUtilities.js'; +import { ApiErrorEvent, ApiRequestEvent, ApiResponseEvent, @@ -138,7 +142,11 @@ export class GeminiChat { } 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( @@ -310,7 +318,7 @@ export class GeminiChat { durationMs, prompt_id, response.usageMetadata, - JSON.stringify(response), + getStructuredResponse(response), ); this.sendPromise = (async () => { @@ -546,12 +554,12 @@ export class GeminiChat { allParts.push(...content.parts); } } - + const fullText = getStructuredResponseFromParts(allParts); await this._logApiResponse( durationMs, prompt_id, this.getFinalUsageMetadata(chunks), - JSON.stringify(chunks), + fullText, ); } this.recordHistory(inputContent, outputContent); |
