You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi, I noticed a small issue in your ChatGPT_API_with_finish_reason function. In the exception handler, when max_retries is reached, the function returns only one value ("Error"), but in the success case it returns a tuple: (content, finish_reason). This inconsistency can cause a "not enough values to unpack" error when someone tries to unpack the return value (e.g., response, status = ChatGPT_API_with_finish_reason(...)).
It would be better to return a consistent number of values in all code paths—perhaps something like return "Error", "error" or raise an exception instead.
Thanks for sharing your code!
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
-
Hi, I noticed a small issue in your ChatGPT_API_with_finish_reason function. In the exception handler, when max_retries is reached, the function returns only one value ("Error"), but in the success case it returns a tuple: (content, finish_reason). This inconsistency can cause a "not enough values to unpack" error when someone tries to unpack the return value (e.g., response, status = ChatGPT_API_with_finish_reason(...)).
It would be better to return a consistent number of values in all code paths—perhaps something like return "Error", "error" or raise an exception instead.
Thanks for sharing your code!
Beta Was this translation helpful? Give feedback.
All reactions