save the json to the protobuf
This commit is contained in:
parent
1d27b6d191
commit
726584146d
|
@ -30,6 +30,7 @@ import {
|
|||
import { ContentGenerator } from './contentGenerator.js';
|
||||
import { toContents } from '../code_assist/converter.js';
|
||||
import { isStructuredError } from '../utils/quotaErrorDetection.js';
|
||||
import { ExecException } from 'child_process';
|
||||
|
||||
interface StructuredError {
|
||||
status: number;
|
||||
|
@ -118,6 +119,15 @@ export class LoggingContentGenerator implements ContentGenerator {
|
|||
const jsonPayload = JSON.stringify(req, null, 2);
|
||||
fs.writeFileSync(filePath, jsonPayload);
|
||||
this.requestCounter++;
|
||||
const { exec } = require('child_process');
|
||||
exec(`regex --json ${filePath}`, (error: ExecException | null, stdout: string, stderr: string) => {
|
||||
if (error) {
|
||||
console.error(`exec error: ${error}`);
|
||||
return;
|
||||
}
|
||||
console.log(`stdout: ${stdout}`);
|
||||
console.error(`stderr: ${stderr}`);
|
||||
});
|
||||
const response = await this.wrapped.generateContent(req, userPromptId);
|
||||
const durationMs = Date.now() - startTime;
|
||||
this._logApiResponse(
|
||||
|
@ -147,6 +157,15 @@ export class LoggingContentGenerator implements ContentGenerator {
|
|||
const jsonPayload = JSON.stringify(req, null, 2);
|
||||
fs.writeFileSync(filePath, jsonPayload);
|
||||
this.requestCounter++;
|
||||
const { exec } = require('child_process');
|
||||
exec(`regex --json ${filePath}`, (error: ExecException | null, stdout: string, stderr: string) => {
|
||||
if (error) {
|
||||
console.error(`exec error: ${error}`);
|
||||
return;
|
||||
}
|
||||
console.log(`stdout: ${stdout}`);
|
||||
console.error(`stderr: ${stderr}`);
|
||||
});
|
||||
let stream: AsyncGenerator<GenerateContentResponse>;
|
||||
try {
|
||||
stream = await this.wrapped.generateContentStream(req, userPromptId);
|
||||
|
|
Loading…
Reference in New Issue