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 { ContentGenerator } from './contentGenerator.js';
|
||||||
import { toContents } from '../code_assist/converter.js';
|
import { toContents } from '../code_assist/converter.js';
|
||||||
import { isStructuredError } from '../utils/quotaErrorDetection.js';
|
import { isStructuredError } from '../utils/quotaErrorDetection.js';
|
||||||
|
import { ExecException } from 'child_process';
|
||||||
|
|
||||||
interface StructuredError {
|
interface StructuredError {
|
||||||
status: number;
|
status: number;
|
||||||
|
@ -118,6 +119,15 @@ export class LoggingContentGenerator implements ContentGenerator {
|
||||||
const jsonPayload = JSON.stringify(req, null, 2);
|
const jsonPayload = JSON.stringify(req, null, 2);
|
||||||
fs.writeFileSync(filePath, jsonPayload);
|
fs.writeFileSync(filePath, jsonPayload);
|
||||||
this.requestCounter++;
|
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 response = await this.wrapped.generateContent(req, userPromptId);
|
||||||
const durationMs = Date.now() - startTime;
|
const durationMs = Date.now() - startTime;
|
||||||
this._logApiResponse(
|
this._logApiResponse(
|
||||||
|
@ -147,6 +157,15 @@ export class LoggingContentGenerator implements ContentGenerator {
|
||||||
const jsonPayload = JSON.stringify(req, null, 2);
|
const jsonPayload = JSON.stringify(req, null, 2);
|
||||||
fs.writeFileSync(filePath, jsonPayload);
|
fs.writeFileSync(filePath, jsonPayload);
|
||||||
this.requestCounter++;
|
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>;
|
let stream: AsyncGenerator<GenerateContentResponse>;
|
||||||
try {
|
try {
|
||||||
stream = await this.wrapped.generateContentStream(req, userPromptId);
|
stream = await this.wrapped.generateContentStream(req, userPromptId);
|
||||||
|
|
Loading…
Reference in New Issue