Closed XInTheDark closed 1 month ago
This potentially appears to be a fetch polyfill issue. I realize that you are using Raycast and need to polyfill fetch (I develop extensions for it too). I recommend using the node-fetch
polyfill, as others may not work too well. The entirety of streaming was redesigned (not to mention rewritten) with SSE, so it makes sense that there may be minor differences. Please attempt to use node-fetch
, and if you are/it still doesn't work, please let me know!
I will try to see if I can make fallback streaming implementations for different polyfills later.
Sorry for the inconvenience about the incompatibility, by the way... it's rather difficult to keep it completely backwards compatible especially through a change in implementation and a rewrite.
Thanks for the solution! I changed to node-fetch
and everything works great now :)
Do you mind sharing which polyfill you used before so I can debug further?
Sure! I used node-fetch-polyfill
, latest version. The only difference was which fetch
function was passed when initialising the Gemini object.
Ah yes, I can reproduce now (I was using my own API wrong 🤦♂️). I am implementing a fallback solution (which works for native fetch and node-fetch-polyfill
but not node-fetch
) in case AsyncIterators are not defined (i.e. for node-fetch-polyfill
or Safari native fetch) so that it should be a complete streaming support for all environments.
@XInTheDark The fix is now applied, with a direct response.body.getReader()
used as the default (which works for most fetch polyfills except node-fetch
), then if that fails, the fallback is AsyncIterator
, which works with a lot less environments, but it does for node-fetch
. It is available in Gemini AI v2.1.1
Hi! So my code looks like this:
Pretty standard stuff, and it works perfectly with v1.1.0 of your API. But with the exact same code, after upgrading to v2.0.0 and later, I get the following error:
As the new API is supposed to be fully compatible with previous versions, could you check if something has been changed? I'm also happy to provide more debug details if you need them. Thanks in advance!