Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix handling of empty choices array in Azure OpenAI API integration #699

Merged
merged 1 commit into from
May 12, 2024

Conversation

PeterDaveHello
Copy link
Contributor

This commit refines the error handling for the Azure OpenAI API integration to address the 'n.choices[0] is undefined' error by ensuring 'data.choices' and 'data.choices[0]' are properly checked before access. This update is necessary due to the behavior changes introduced in the API version update (#684), which can result in empty 'choices' arrays.

Fix #698.

@josStorer
Copy link
Owner

I think we should also add a condition data.choices.length > 0

This commit refines the error handling for the Azure OpenAI API
integration to address the 'n.choices[0] is undefined' error by ensuring
'data.choices' and 'data.choices[0]' are properly checked before access.
This update is necessary due to the behavior changes introduced in the
API version update (josStorer#684), which can result in empty 'choices' arrays.

Fix josStorer#698.
@PeterDaveHello
Copy link
Contributor Author

Done!

@josStorer josStorer merged commit d4a4971 into josStorer:master May 12, 2024
1 check passed
@PeterDaveHello PeterDaveHello deleted the FixAzureOpenAI branch May 12, 2024 11:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Azure OpenAI always returns: n.choices[0] is undefined error
2 participants