From 044b3d0de89e4e62d65d12ab1cf9518e71ea1411 Mon Sep 17 00:00:00 2001 From: Josh Fleming Date: Wed, 4 Dec 2024 15:47:45 -0500 Subject: [PATCH] Handle MALFORMED_FUNCTION_CALL in google gemini api (#70) --- src/ax/ai/google-gemini/api.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/ax/ai/google-gemini/api.ts b/src/ax/ai/google-gemini/api.ts index 6da0885..f8f6d4d 100644 --- a/src/ax/ai/google-gemini/api.ts +++ b/src/ax/ai/google-gemini/api.ts @@ -392,9 +392,11 @@ export class AxAIGoogleGemini extends AxBaseAI< throw new Error('Finish reason: SAFETY'); case 'RECITATION': throw new Error('Finish reason: RECITATION'); + case 'MALFORMED_FUNCTION_CALL': + throw new Error('Finish reason: MALFORMED_FUNCTION_CALL'); } - if (!candidate.content.parts) { + if (!candidate.content || !candidate.content.parts) { return result; }