From 79d0c96b203ce53f2f7233b05c2dc4d104ca5676 Mon Sep 17 00:00:00 2001 From: Enrico Ros Date: Tue, 2 Apr 2024 20:53:26 -0700 Subject: [PATCH] Gemini: call out RECITATIONS --- src/modules/llms/server/llm.server.streaming.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/modules/llms/server/llm.server.streaming.ts b/src/modules/llms/server/llm.server.streaming.ts index 5e33577eb..b468761d7 100644 --- a/src/modules/llms/server/llm.server.streaming.ts +++ b/src/modules/llms/server/llm.server.streaming.ts @@ -389,7 +389,9 @@ function createStreamParserGemini(modelName: string): AIStreamParser { if (!singleCandidate.content) { if (singleCandidate.finishReason === 'MAX_TOKENS') return { text: ` ${USER_SYMBOL_MAX_TOKENS}`, close: true }; - throw new Error('server response missing content'); + if (singleCandidate.finishReason === 'RECITATION') + throw new Error('generation stopped due to RECITATION'); + throw new Error(`server response missing content (finishReason: ${singleCandidate?.finishReason})`); } // expect a single part