ai: add null check for gemini annotations

This commit is contained in:
end-4
2025-05-19 09:37:47 +02:00
parent 2b393708b7
commit 671d2463b8
+3 -3
View File
@@ -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