From 7a1c543ec5ce6146c3b4677b7aafd14d6a274ec9 Mon Sep 17 00:00:00 2001 From: bf62963 <132244937+bf62963@users.noreply.github.com> Date: Mon, 1 May 2023 03:53:27 +0000 Subject: [PATCH] Quick Fix to Enable Using gpt-4-0314 --- public/index.html | 1 + public/scripts/openai.js | 2 +- server.js | 4 ++-- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/public/index.html b/public/index.html index 5c2516511..31e3da403 100644 --- a/public/index.html +++ b/public/index.html @@ -126,6 +126,7 @@ + diff --git a/public/scripts/openai.js b/public/scripts/openai.js index efb9742a7..4a4d274e5 100644 --- a/public/scripts/openai.js +++ b/public/scripts/openai.js @@ -1035,7 +1035,7 @@ $(document).ready(function () { const value = $(this).val(); oai_settings.openai_model = value; - if (value == 'gpt-4') { + if (value == 'gpt-4' || value == 'gpt-4-0314') { $('#openai_max_context').attr('max', gpt4_max); } else if (value == 'gpt-4-32k') { diff --git a/server.js b/server.js index 9237e5fd3..8a343ba20 100644 --- a/server.js +++ b/server.js @@ -2159,7 +2159,7 @@ app.post("/openai_bias", jsonParser, async function (request, response) { let result = {}; - const tokenizer = tiktoken.encoding_for_model(request.query.model); + const tokenizer = tiktoken.encoding_for_model(request.query.model === 'gpt-4-0314' ? 'gpt-4' : request.query.model); for (const entry of request.body) { if (!entry || !entry.text) { @@ -2305,7 +2305,7 @@ app.post("/tokenize_openai", jsonParser, function (request, response_tokenize_op const tokensPerMessage = request.query.model.includes('gpt-4') ? 3 : 4; const tokensPadding = 3; - const tokenizer = tiktoken.encoding_for_model(request.query.model); + const tokenizer = tiktoken.encoding_for_model(request.query.model === 'gpt-4-0314' ? 'gpt-4' : request.query.model); let num_tokens = 0; for (const msg of request.body) {