From 6ee7d7c96f1002674a5dcbc2ce469200184e9e04 Mon Sep 17 00:00:00 2001 From: mic Date: Tue, 10 Jun 2025 08:09:37 +0200 Subject: [PATCH] [OpenAIComp] Add error handling for empty choices in parsed response --- js/workers/model-worker-openai_comp.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/js/workers/model-worker-openai_comp.js b/js/workers/model-worker-openai_comp.js index 7df91d49..4882800f 100644 --- a/js/workers/model-worker-openai_comp.js +++ b/js/workers/model-worker-openai_comp.js @@ -113,6 +113,10 @@ self.onmessage = async function(event) { for (const parsedLine of parsedLines) { const { choices } = parsedLine; + if (!choices || choices.length === 0) { + taLog.error("No choices found in parsed line: " + JSON.stringify(parsedLine)); + continue; + } const { delta } = choices[0]; const { content } = delta; // Update the UI with the new content