ai: gemini: fix random json spilling

This commit is contained in:
end-4
2025-07-21 17:56:31 +07:00
parent 0d9d11b2e0
commit 349700d7fb
+3 -2
View File
@@ -613,7 +613,8 @@ Singleton {
"text": chunk?.web?.title, "text": chunk?.web?.title,
"url": chunk?.web?.uri, "url": chunk?.web?.uri,
} }
}); }) ?? [];
const annotations = dataJson.candidates[0]?.groundingMetadata?.groundingSupports?.map(citation => { const annotations = dataJson.candidates[0]?.groundingMetadata?.groundingSupports?.map(citation => {
return { return {
"type": "url_citation", "type": "url_citation",
@@ -628,7 +629,7 @@ Singleton {
requester.message.annotations = annotations; requester.message.annotations = annotations;
// console.log(JSON.stringify(requester.message, null, 2)); // console.log(JSON.stringify(requester.message, null, 2));
} catch (e) { } catch (e) {
console.log("[AI] Could not parse response from stream: ", e); console.log("[AI] Gemini: Could not parse buffer: ", e);
requester.message.rawContent += requester.geminiBuffer; requester.message.rawContent += requester.geminiBuffer;
requester.message.content += requester.geminiBuffer requester.message.content += requester.geminiBuffer
} finally { } finally {