Skip to content

Commit 38e1708

Browse files
committed
AIX: Gemini: Parser: improve finish reason reporting
1 parent fe4e755 commit 38e1708

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/modules/aix/server/dispatch/chatGenerate/parsers/gemini.parser.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -305,7 +305,7 @@ export function createGeminiGenerateContentResponseParser(requestedModelName: st
305305

306306
// NEW NOTE:
307307
// 'STOP' seems to only be sent at the end now
308-
pt.setTokenStopReason('ok')
308+
pt.setTokenStopReason('ok');
309309
pt.setDialectEnded('done-dialect'); // Gemini: generation finished successfully
310310
break;
311311

@@ -353,10 +353,10 @@ export function createGeminiGenerateContentResponseParser(requestedModelName: st
353353
'MISSING_THOUGHT_SIGNATURE': ['cg-issue', 'Generation stopped: request has at least one Gemini thought signature missing', null],
354354
'FINISH_REASON_UNSPECIFIED': ['cg-issue', 'Generation stopped and no reason was given', null],
355355
} as const;
356-
const reason = reasonMap[candidate0.finishReason];
356+
const reason = reasonMap[candidate0.finishReason] || ['cg-issue', `Generation stopped due to unknown reason: ${candidate0.finishReason || 'reason unknown'}`, null];
357357
pt.setTokenStopReason(reason[0]);
358358
// append finishMessage if available for more context
359-
const issueMessage = candidate0.finishMessage ? `${reason[1]}: ${candidate0.finishMessage}` : reason[1];
359+
const issueMessage = candidate0.finishMessage ? `${reason[1]}. ${candidate0.finishReason}: ${candidate0.finishMessage}.` : reason[1];
360360
return pt.setDialectTerminatingIssue(issueMessage, reason[2], false);
361361

362362
default:

0 commit comments

Comments
 (0)