Gemini inline images (#3681)

* Gemini images for non-streaming

* Parse images on stream

* Add toggle for image request

* Add extraction params to extractImageFromData

* Add explicit break and return

* Add more JSdoc to processImageAttachment

* Add file name prefix

* Add object argument for saveReply

* Add defaults to saveReply params

* Use type for saveReply result

* Change type check in saveReply backward compat
This commit is contained in:
Cohee
2025-03-14 20:15:04 +02:00
committed by GitHub
parent 0d2bf00810
commit 0017358f8b
5 changed files with 155 additions and 16 deletions

View File

@ -138,10 +138,11 @@ async function* parseStreamData(json) {
for (let i = 0; i < json.candidates.length; i++) {
const isNotPrimary = json.candidates?.[0]?.index > 0;
const hasToolCalls = json?.candidates?.[0]?.content?.parts?.some(p => p?.functionCall);
const hasInlineData = json?.candidates?.[0]?.content?.parts?.some(p => p?.inlineData);
if (isNotPrimary || json.candidates.length === 0) {
return null;
}
if (hasToolCalls) {
if (hasToolCalls || hasInlineData) {
yield { data: json, chunk: '' };
return;
}