Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 10 additions & 3 deletions src/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -496,8 +496,7 @@ ${conversation}`;
{ role: 'system', content: systemPrompt },
{ role: 'user', content: prompt },
],
response_format: { type: 'json_object' },
max_tokens: 150,
max_tokens: 200,
temperature: 0.3,
});

Expand Down Expand Up @@ -527,7 +526,15 @@ ${conversation}`;
reject(new Error(result.error.message || JSON.stringify(result.error)));
return;
}
const content = result.choices[0].message.content;
const msg = result.choices && result.choices[0] && result.choices[0].message;
// Reasoning models may put output in reasoning_content or content
const content = (msg && msg.content) || (msg && msg.reasoning_content) || '';
if (!content) {
// Log full response for debugging
log('ERROR', 'LLM empty content, full response: ' + JSON.stringify(result).slice(0, 500));
reject(new Error('LLM returned empty content. If using a reasoning model, it may not support structured output.'));
return;
}
let title;
try {
title = JSON.parse(content).title;
Expand Down
Loading