Verbose message logging only when debug = true

This commit is contained in:
Badri Narayanan S
2025-12-24 20:31:39 +05:30
parent 0edc718672
commit 943a4dcb20

View File

@@ -250,6 +250,7 @@ app.post('/v1/messages', async (req, res) => {
console.log(`[API] Request for model: ${request.model}, stream: ${!!stream}`);
// Debug: Log message structure to diagnose tool_use/tool_result ordering
if (process.env.DEBUG) {
console.log('[API] Message structure:');
messages.forEach((msg, i) => {
const contentTypes = Array.isArray(msg.content)
@@ -257,6 +258,7 @@ app.post('/v1/messages', async (req, res) => {
: (typeof msg.content === 'string' ? 'text' : 'unknown');
console.log(` [${i}] ${msg.role}: ${contentTypes}`);
});
}
if (stream) {
// Handle streaming response