From ed1e41c4f129cf14cc91f2ae688657a7cd3b4088 Mon Sep 17 00:00:00 2001 From: Peter Dave Hello Date: Fri, 24 Nov 2023 11:58:37 +0800 Subject: [PATCH] feat: support the latest GPT-4 Turbo (gpt-4-1106-preview) model (#1968) Reference: - https://platform.openai.com/docs/models/gpt-4-and-gpt-4-turbo - https://openai.com/blog/new-models-and-developer-products-announced-at-devday#gpt-4-turbo-with-128k-context --- README.md | 2 +- service/src/chatgpt/index.ts | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 5d2864a..bc890f6 100644 --- a/README.md +++ b/README.md @@ -217,7 +217,7 @@ services: # API接口地址,可选,设置 OPENAI_API_KEY 时可用 OPENAI_API_BASE_URL: xxx # API模型,可选,设置 OPENAI_API_KEY 时可用,https://platform.openai.com/docs/models - # gpt-4, gpt-4-0314, gpt-4-0613, gpt-4-32k, gpt-4-32k-0314, gpt-4-32k-0613, gpt-3.5-turbo-16k, gpt-3.5-turbo-16k-0613, gpt-3.5-turbo, gpt-3.5-turbo-0301, gpt-3.5-turbo-0613, text-davinci-003, text-davinci-002, code-davinci-002 + # gpt-4, gpt-4-1106-preview, gpt-4-0314, gpt-4-0613, gpt-4-32k, gpt-4-32k-0314, gpt-4-32k-0613, gpt-3.5-turbo-16k, gpt-3.5-turbo-16k-0613, gpt-3.5-turbo, gpt-3.5-turbo-0301, gpt-3.5-turbo-0613, text-davinci-003, text-davinci-002, code-davinci-002 OPENAI_API_MODEL: xxx # 反向代理,可选 API_REVERSE_PROXY: xxx diff --git a/service/src/chatgpt/index.ts b/service/src/chatgpt/index.ts index ae3296d..f6104fd 100644 --- a/service/src/chatgpt/index.ts +++ b/service/src/chatgpt/index.ts @@ -53,6 +53,11 @@ let api: ChatGPTAPI | ChatGPTUnofficialProxyAPI options.maxModelTokens = 32768 options.maxResponseTokens = 8192 } + // if use GPT-4 Turbo + else if (model.toLowerCase().includes('1106-preview')) { + options.maxModelTokens = 128000 + options.maxResponseTokens = 4096 + } else { options.maxModelTokens = 8192 options.maxResponseTokens = 2048