Skip to content

Commit

Permalink
Azure OpenAI API fix for gpt-3.5-turbo-16k
Browse files Browse the repository at this point in the history
Signed-off-by: Xtrah <12988459+Xtrah@users.noreply.github.com>
  • Loading branch information
Xtrah committed Jun 30, 2023
1 parent 1d88a86 commit 416c4cd
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions src/api/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ export const getChatCompletion = async (
if (isAzureEndpoint(endpoint) && apiKey) {
headers['api-key'] = apiKey;

const gpt3forAzure = 'gpt-35-turbo';
const model =
config.model === 'gpt-3.5-turbo' ? gpt3forAzure : config.model;
const gpt3forAzure = config.model === 'gpt-3.5-turbo' ? 'gpt-35-turbo' : config.model === 'gpt-3.5-turbo-16k' ? 'gpt-35-turbo-16k' : config.model;

const model = gpt3forAzure;
const apiVersion = '2023-03-15-preview';

const path = `openai/deployments/${model}/chat/completions?api-version=${apiVersion}`;
Expand Down Expand Up @@ -64,9 +64,9 @@ export const getChatCompletionStream = async (
if (isAzureEndpoint(endpoint) && apiKey) {
headers['api-key'] = apiKey;

const gpt3forAzure = 'gpt-35-turbo';
const model =
config.model === 'gpt-3.5-turbo' ? gpt3forAzure : config.model;
const gpt3forAzure = config.model === 'gpt-3.5-turbo' ? 'gpt-35-turbo' : config.model === 'gpt-3.5-turbo-16k' ? 'gpt-35-turbo-16k' : config.model;

const model = gpt3forAzure;
const apiVersion = '2023-03-15-preview';

const path = `openai/deployments/${model}/chat/completions?api-version=${apiVersion}`;
Expand Down Expand Up @@ -94,7 +94,7 @@ export const getChatCompletionStream = async (
if (text.includes('model_not_found')) {
throw new Error(
text +
'\nMessage from Better ChatGPT:\nPlease ensure that you have access to the GPT-4 API!'
'\nMessage from Better ChatGPT:\nPlease ensure that you have access to the GPT-4 API!'
);
} else {
throw new Error(
Expand Down

0 comments on commit 416c4cd

Please sign in to comment.