ztjhz / BetterChatGPT

An amazing UI for OpenAI's ChatGPT (Website + Windows + MacOS + Linux)
http://bettergpt.chat/
Creative Commons Zero v1.0 Universal
8.19k stars 2.77k forks source link

Support for other api-versions for Azrue openai #564

Open detrin opened 8 months ago

detrin commented 8 months ago

Right now I can not use endpoint with api-version=2024-02-15-preview looking at https://learn.microsoft.com/en-us/azure/ai-services/openai/reference?WT.mc_id=AZ-MVP-5004796 I think the cod might be little bit outdated https://github.com/ztjhz/BetterChatGPT/blob/eb18479a6b32cde25cd61770e8f2cb971418db23/src/api/api.ts#L31C1-L45C1

detrin commented 8 months ago

maybe something like this?

const url = new URL(endpoint);

// Gets all query string value
const params = new URLSearchParams(url.search);

// Checking if api-version exist
if (params.has('api-version')) {
  // Getting api-version value and assigning it
  const apiVersion = params.get('api-version');
  console.log(apiVersion);
}

I checked the network tab and yes the request doesn't work when using custom azure endpoint, because it appends the whole path to it, making the URL invalid

detrin commented 8 months ago

I believe I know how to fix it, I will open PR

detrin commented 8 months ago
// according to https://learn.microsoft.com/en-us/azure/ai-services/openai/reference?WT.mc_id=AZ-MVP-5004796
  const apiVersions = [
    '2022-12-01',
    '2023-03-15-preview',
    '2023-05-15',
    '2023-06-01-preview',
    '2023-07-01-preview',
    '2023-08-01-preview',
    '2023-09-01-preview',
    '2023-10-01-preview',
    '2023-12-01-preview',
    '2024-02-15-preview',
    '2024-03-01-preview',
    '2024-02-01'
  ];