From 671d2463b8237a0680edb9c0e5d0b4e68a053aa3 Mon Sep 17 00:00:00 2001 From: end-4 <97237370+end-4@users.noreply.github.com> Date: Mon, 19 May 2025 09:37:47 +0200 Subject: [PATCH] ai: add null check for gemini annotations --- .config/quickshell/services/Ai.qml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.config/quickshell/services/Ai.qml b/.config/quickshell/services/Ai.qml index 495f15efc..f47718f9c 100644 --- a/.config/quickshell/services/Ai.qml +++ b/.config/quickshell/services/Ai.qml @@ -318,14 +318,14 @@ Singleton { const dataJson = JSON.parse(requester.geminiBuffer); const responseContent = dataJson.candidates[0]?.content?.parts[0]?.text requester.message.content += responseContent; - const annotationSources = dataJson.candidates[0]?.groundingMetadata.groundingChunks?.map(chunk => { + const annotationSources = dataJson.candidates[0]?.groundingMetadata?.groundingChunks?.map(chunk => { return { "type": "url_citation", "text": chunk?.web?.title, "url": chunk?.web?.uri, } }); - const annotations = dataJson.candidates[0]?.groundingMetadata.groundingSupports?.map(citation => { + const annotations = dataJson.candidates[0]?.groundingMetadata?.groundingSupports?.map(citation => { return { "type": "url_citation", "start_index": citation.segment?.startIndex, @@ -403,7 +403,7 @@ Singleton { stdout: SplitParser { onRead: data => { - // console.log("RAW DATA: ", data); + console.log("RAW DATA: ", data); if (data.length === 0) return; // Handle response line