diff --git a/service/src/chatgpt/index.ts b/service/src/chatgpt/index.ts index 3ade78d..fc25bd2 100644 --- a/service/src/chatgpt/index.ts +++ b/service/src/chatgpt/index.ts @@ -45,6 +45,19 @@ let api: ChatGPTAPI | ChatGPTUnofficialProxyAPI debug: true, } + // increase max token limit if use gpt-4 + if (model.toLowerCase().includes('gpt-4')) { + // if use 32k model + if (model.toLowerCase().includes('32k')) { + options.maxModelTokens = 32768 + options.maxResponseTokens = 8192 + } + else { + options.maxModelTokens = 8192 + options.maxResponseTokens = 2048 + } + } + if (isNotEmptyString(OPENAI_API_BASE_URL)) options.apiBaseUrl = `${OPENAI_API_BASE_URL}/v1`