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

Azure OpenAI always returns: n.choices[0] is undefined error #698

Closed
PeterDaveHello opened this issue May 12, 2024 · 2 comments · Fixed by #699
Closed

Azure OpenAI always returns: n.choices[0] is undefined error #698

PeterDaveHello opened this issue May 12, 2024 · 2 comments · Fixed by #699

Comments

@PeterDaveHello
Copy link
Contributor

Describe the bug
问题描述

Azure OpenAI always returns: n.choices[0] is undefined error as shown in the screenshot below.

To Reproduce
如何复现
Steps to reproduce the behavior:

Use ChatGPT (Azure) and send any prompt.

Expected behavior
期望行为

Response as normal.

Screenshots
截图说明

image

Please complete the following information):
请补全以下内容

  • OS: Ubuntu 22.04
  • Browser: Firefox v125.0.3
  • Extension Version: v2.5.4

Additional context
其他

I checked recent changes for Azure OpenAI. This PR may be related: #684

@PeterDaveHello
Copy link
Contributor Author

Maybe the reason why is that the new API version responds empty choices[] first:

{
  "choices": [],
  "created": 0,
  "id": "",
  "model": "",
  "object": "",
  "prompt_filter_results": [
    {
      "prompt_index": 0,
      "content_filter_results": {
        "hate": {
          "filtered": false,
          "severity": "safe"
        },
        "self_harm": {
          "filtered": false,
          "severity": "safe"
        },
        "sexual": {
          "filtered": false,
          "severity": "safe"
        },
        "violence": {
          "filtered": false,
          "severity": "safe"
        }
      }
    }
  ]
}

@PeterDaveHello
Copy link
Contributor Author

Okay, that's my fault 😓

PeterDaveHello added a commit to PeterDaveHello/chatGPTBox that referenced this issue May 12, 2024
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 added a commit to PeterDaveHello/chatGPTBox that referenced this issue May 12, 2024
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.
josStorer pushed a commit that referenced this issue May 12, 2024
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.
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 a pull request may close this issue.

1 participant