EvanZhouDev / gemini-ai

The simpler JavaScript Gemini SDK
https://www.npmjs.com/package/gemini-ai
GNU General Public License v3.0
95 stars 16 forks source link

getTextObject is throwing occasionally #22

Open danew opened 4 days ago

danew commented 4 days ago

Occasionally when calling gemini.ask the response throws the following error:

256 |   }
257 |   return parts;
258 | };
259 | var _Gemini = class _Gemini {
260 |   constructor(key, options = {}) {
261 |     this.getTextObject = (response) => response.candidates[0].content.parts[0];
                                                                    ^
TypeError: undefined is not an object (evaluating 'response.candidates[0].content.parts')
      at /Users/danew/development/github/SaneFYI/dbjs/node_modules/gemini-ai/dist/index.mjs:261:63
      at /Users/danew/development/github/SaneFYI/dbjs/node_modules/gemini-ai/dist/index.mjs:275:23

https://github.com/EvanZhouDev/gemini-ai/blob/5f843dfd2c86dd7958fd53213007b8330a25948a/src/index.ts#L282