Closed Anton-Plagemann closed 1 year ago
Hey @Anton-Plagemann, great catch here! (pun intended)
So I've added a throw clause to the catch block and I'm now also throwing an error whenever the parsed blob doesn't contain completion choices (which likely indicates there was an error).
Give it a try with the newest version:
npm i openai-ext@latest
Hope that solves your issue, keep me posted!
Hi @justinmahar,
Thank you so much for your quick response and for implementing the changes! I really appreciate it. I have updated the library in my application and will test it out. I'll let you know as soon as I have any results (could take some time to wait for the next error 😄).
Thanks again for your help!
Hi @justinmahar,
I now can confirm it works as expected and all errors are passed through 🥳
Surprisingly theres also sometimes a Unexpected end of JSON input
error, but it seems to be tolerable (maybe 1 or 2 tokens get lost but thats ok 😊).
Thanks again for the update!
Woohoo!! 🍻
Hi @justinmahar,
first, thanks for this very nice library! It has saved me some valuable time! 🚀
I have an issue with the exception handling which we could optimize maybe: Sometimes OpenAI responds with a JSON like this:
In this case the error gets catched silently in this code block:
https://github.com/justinmahar/openai-ext/blob/8364d8b1f5e98d095eabb7223db17989df260f2f/src/OpenAIExt.ts#L194-L197
Unfortunately theres no posibility for overlying code to identify this error and inform the user or retry the request.
onContent
will be called within this case.
I would instead recomment to throw such an error.
Is that something you we could change? If it is helpful, I could also work on a fix and submit a PR 😊