From 7474b2c14971d2d9584c4b129396f9332ed87b7b Mon Sep 17 00:00:00 2001 From: Peter Dave Hello Date: Fri, 19 Jul 2024 11:07:35 +0800 Subject: [PATCH] Add GPT-4o mini support (#2102) Reference: - https://platform.openai.com/docs/models/gpt-4o-mini - https://openai.com/index/gpt-4o-mini-advancing-cost-efficient-intelligence/ --- README.md | 2 +- README.zh.md | 2 +- service/src/chatgpt/index.ts | 4 ++++ 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 38a5c6e..45f1fab 100644 --- a/README.md +++ b/README.md @@ -216,7 +216,7 @@ services: # API interface address, optional, available when OPENAI_API_KEY is set OPENAI_API_BASE_URL: xxx # API model, optional, available when OPENAI_API_KEY is set, https://platform.openai.com/docs/models - # gpt-4, gpt-4o, gpt-4-turbo, gpt-4-turbo-preview, gpt-4-0125-preview, 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 + # gpt-4, gpt-4o, gpt-4o-mini, gpt-4-turbo, gpt-4-turbo-preview, gpt-4-0125-preview, 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 # reverse proxy, optional API_REVERSE_PROXY: xxx diff --git a/README.zh.md b/README.zh.md index ceabef7..37e985f 100644 --- a/README.zh.md +++ b/README.zh.md @@ -220,7 +220,7 @@ services: # API接口地址,可选,设置 OPENAI_API_KEY 时可用 OPENAI_API_BASE_URL: xxx # API模型,可选,设置 OPENAI_API_KEY 时可用,https://platform.openai.com/docs/models - # gpt-4, gpt-4o, gpt-4-turbo, gpt-4-turbo-preview, gpt-4-0125-preview, 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 + # gpt-4, gpt-4o, gpt-4o-mini, gpt-4-turbo, gpt-4-turbo-preview, gpt-4-0125-preview, 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 380a901..6752b76 100644 --- a/service/src/chatgpt/index.ts +++ b/service/src/chatgpt/index.ts @@ -53,6 +53,10 @@ let api: ChatGPTAPI | ChatGPTUnofficialProxyAPI options.maxModelTokens = 32768 options.maxResponseTokens = 8192 } + else if (/-4o-mini/.test(model.toLowerCase())) { + options.maxModelTokens = 128000 + options.maxResponseTokens = 16384 + } // if use GPT-4 Turbo or GPT-4o else if (/-preview|-turbo|o/.test(model.toLowerCase())) { options.maxModelTokens = 128000