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

Update api.ts #483

Merged
merged 2 commits into from
Nov 11, 2023
Merged

Update api.ts #483

merged 2 commits into from
Nov 11, 2023

Conversation

yfw918
Copy link
Contributor

@yfw918 yfw918 commented Nov 8, 2023

Update Azure API version. Sorry for closing PR by mistake earlier.
https://learn.microsoft.com/en-us/azure/ai-services/openai/reference

Update Azure API version. Sorry for closing PR by mistake earlier.
https://learn.microsoft.com/en-us/azure/ai-services/openai/reference
@yfw918
Copy link
Contributor Author

yfw918 commented Nov 9, 2023

I've noticed that the newer API version have different return values than the older version, so other code changes may be needed, here are some examples:

When API version is "2023-03-15-preview" and "2023-05-15":

{
  "choices": [
    {
      "finish_reason": "stop",
      "index": 0,
      "message": {
        "content": "This is a response to your test. How can I assist you?",
        "role": "assistant"
      }
    }
  ],
  "created": 1699518695,
  "id": "chatcmpl-8IujnmYS386HmiSJp3U6cFy5uzs1L",
  "model": "gpt-35-turbo",
  "object": "chat.completion",
  "usage": {
    "completion_tokens": 14,
    "prompt_tokens": 8,
    "total_tokens": 22
  }
}

Newer version, such as "2023-09-01-preview":

{
  "choices": [
    {
      "content_filter_results": {
        "hate": {
          "filtered": false,
          "severity": "safe"
        },
        "self_harm": {
          "filtered": false,
          "severity": "safe"
        },
        "sexual": {
          "filtered": false,
          "severity": "safe"
        },
        "violence": {
          "filtered": false,
          "severity": "safe"
        }
      },
      "finish_reason": "stop",
      "index": 0,
      "message": {
        "content": "Hello! How can I assist you today?",
        "role": "assistant"
      }
    }
  ],
  "created": 1699518879,
  "id": "chatcmpl-8Iumlm9xpj8AXenBhdQ7o9qL9qLnp",
  "model": "gpt-35-turbo",
  "object": "chat.completion",
  "prompt_filter_results": [
    {
      "content_filter_results": {
        "hate": {
          "filtered": false,
          "severity": "safe"
        },
        "self_harm": {
          "filtered": false,
          "severity": "safe"
        },
        "sexual": {
          "filtered": false,
          "severity": "safe"
        },
        "violence": {
          "filtered": false,
          "severity": "safe"
        }
      },
      "prompt_index": 0
    }
  ],
  "usage": {
    "completion_tokens": 9,
    "prompt_tokens": 8,
    "total_tokens": 17
  }
}

@yfw918
Copy link
Contributor Author

yfw918 commented Nov 11, 2023

@ztjhz An hour ago you updated api.ts and then Azure GPT4 doesn't work. It says: "Message from Better ChatGPT.
Invalid API endpoint! We recommend you to check your free API endpoint.". But I tested locally and the api is working fine.

@ztjhz
Copy link
Owner

ztjhz commented Nov 11, 2023

@yfw918 A fix has been pushed. You can try to see if it is valid.

@yfw918
Copy link
Contributor Author

yfw918 commented Nov 11, 2023

@yfw918 A fix has been pushed. You can try to see if it is valid.

Almost there, you missed a dash, I added it.

@yfw918
Copy link
Contributor Author

yfw918 commented Nov 11, 2023

@yfw918 A fix has been pushed. You can try to see if it is valid.

Almost there, you missed a dash, I added it.

1

@ztjhz ztjhz merged commit dd77b18 into ztjhz:main Nov 11, 2023
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.

2 participants