feat(runner): add structured gemini API request/response logging
This commit is contained in:
@@ -121,12 +121,33 @@ export async function callGeminiChat(opts: {
|
||||
const fns = toGeminiFunctions(opts.tools ?? []);
|
||||
if (fns) config.tools = fns;
|
||||
|
||||
console.log("\n========================================================");
|
||||
console.log("➡️ [GEMINI API REQUEST]");
|
||||
console.log("========================================================");
|
||||
console.log(
|
||||
`System Prompt: ${config.systemInstruction ? config.systemInstruction.slice(0, 1000) + "..." : "None"}`,
|
||||
);
|
||||
console.log(
|
||||
"Contents Payload:",
|
||||
JSON.stringify(toGeminiContents(opts.messages), null, 2),
|
||||
);
|
||||
console.log("========================================================\n");
|
||||
|
||||
const response = await ai.models.generateContent({
|
||||
model: GEMINI_MODEL,
|
||||
contents: toGeminiContents(opts.messages),
|
||||
config,
|
||||
});
|
||||
|
||||
console.log("\n========================================================");
|
||||
console.log("⬅️ [GEMINI API RESPONSE]");
|
||||
console.log("========================================================");
|
||||
console.log(
|
||||
"Raw Candidates:",
|
||||
JSON.stringify(response.candidates, null, 2),
|
||||
);
|
||||
console.log("========================================================\n");
|
||||
|
||||
let text = "";
|
||||
let thoughts = "";
|
||||
const toolCalls: ToolCall[] = [];
|
||||
@@ -183,6 +204,18 @@ export async function* streamGeminiChat(opts: {
|
||||
const fns = toGeminiFunctions(opts.tools ?? []);
|
||||
if (fns) config.tools = fns;
|
||||
|
||||
console.log("\n========================================================");
|
||||
console.log("➡️ [GEMINI STREAM REQUEST]");
|
||||
console.log("========================================================");
|
||||
console.log(
|
||||
`System Prompt: ${config.systemInstruction ? config.systemInstruction.slice(0, 1000) + "..." : "None"}`,
|
||||
);
|
||||
console.log(
|
||||
"Contents Payload:",
|
||||
JSON.stringify(toGeminiContents(opts.messages), null, 2),
|
||||
);
|
||||
console.log("========================================================\n");
|
||||
|
||||
const streamResult = await ai.models.generateContentStream({
|
||||
model: GEMINI_MODEL,
|
||||
contents: toGeminiContents(opts.messages),
|
||||
|
||||
Reference in New Issue
Block a user