diff --git a/service/.env.example b/service/.env.example index a7a7747..ac8e9d6 100644 --- a/service/.env.example +++ b/service/.env.example @@ -16,6 +16,9 @@ API_REVERSE_PROXY= # timeout TIMEOUT_MS=100000 +# Rate Limit +MAX_REQUEST_PER_HOUR= + # Secret key AUTH_SECRET_KEY= @@ -28,5 +31,3 @@ SOCKS_PROXY_PORT= # HTTPS PROXY HTTPS_PROXY= -# Rate Limit -MAX_REQUEST_PER_HOUR= diff --git a/service/package.json b/service/package.json index e2309d6..4089b9e 100644 --- a/service/package.json +++ b/service/package.json @@ -25,7 +25,7 @@ }, "dependencies": { "axios": "^1.3.4", - "chatgpt": "^5.0.10", + "chatgpt": "^5.1.2", "dotenv": "^16.0.3", "esno": "^0.16.3", "express": "^4.18.2", diff --git a/service/pnpm-lock.yaml b/service/pnpm-lock.yaml index ddbfb44..04e84d3 100644 --- a/service/pnpm-lock.yaml +++ b/service/pnpm-lock.yaml @@ -5,7 +5,7 @@ specifiers: '@types/express': ^4.17.17 '@types/node': ^18.14.6 axios: ^1.3.4 - chatgpt: ^5.0.10 + chatgpt: ^5.1.2 dotenv: ^16.0.3 eslint: ^8.35.0 esno: ^0.16.3 @@ -21,7 +21,7 @@ specifiers: dependencies: axios: 1.3.4 - chatgpt: 5.0.10 + chatgpt: 5.1.2 dotenv: 16.0.3 esno: 0.16.3 express: 4.18.2 @@ -156,8 +156,8 @@ packages: chalk: 2.4.2 js-tokens: 4.0.0 - /@dqbd/tiktoken/0.4.0: - resolution: {integrity: sha512-iaHgmwKAOqowBFZKxelyszoeGLoNw62eOULcmyme1aA1Ymr3JgYl0V7jwpuUm7fksalycZajx3loFn9TRUaviw==} + /@dqbd/tiktoken/1.0.2: + resolution: {integrity: sha512-AjGTBRWsMoVmVeN55NLyupyM8TNamOUBl6tj5t/leLDVup3CFGO9tVagNL1jf3GyZLkWZSTmYVbPQ/M2LEcNzw==} dev: false /@esbuild-kit/cjs-loader/2.4.2: @@ -922,12 +922,12 @@ packages: resolution: {integrity: sha512-mKKUkUbhPpQlCOfIuZkvSEgktjPFIsZKRRbC6KWVEMvlzblj3i3asQv5ODsrwt0N3pHAEvjP8KTQPHkp0+6jOg==} dev: true - /chatgpt/5.0.10: - resolution: {integrity: sha512-R3vtPlhCapFLkDXED0Cnt1DBcOZAXygr0M5U5kbSI0Fwm4uDQmc7qoIOnr17rd8eaa0JO/UDOevJdEWvd079qA==} + /chatgpt/5.1.2: + resolution: {integrity: sha512-b/NnDQHDOpouK+gmhUCKcKuvnKEh+DotwXlP6Qgw1mqmkcfVl9Wt3/3noT8jbGJpMEpFOfzexXn5Rehpea1N0w==} engines: {node: '>=14'} hasBin: true dependencies: - '@dqbd/tiktoken': 0.4.0 + '@dqbd/tiktoken': 1.0.2 cac: 6.7.14 conf: 11.0.1 eventsource-parser: 0.0.5 diff --git a/service/src/chatgpt/index.ts b/service/src/chatgpt/index.ts index 772e4df..3ade78d 100644 --- a/service/src/chatgpt/index.ts +++ b/service/src/chatgpt/index.ts @@ -35,6 +35,7 @@ let api: ChatGPTAPI | ChatGPTUnofficialProxyAPI // More Info: https://github.com/transitive-bullshit/chatgpt-api if (isNotEmptyString(process.env.OPENAI_API_KEY)) { + const OPENAI_API_BASE_URL = process.env.OPENAI_API_BASE_URL const OPENAI_API_MODEL = process.env.OPENAI_API_MODEL const model = isNotEmptyString(OPENAI_API_MODEL) ? OPENAI_API_MODEL : 'gpt-3.5-turbo' @@ -44,8 +45,8 @@ let api: ChatGPTAPI | ChatGPTUnofficialProxyAPI debug: true, } - if (isNotEmptyString(process.env.OPENAI_API_BASE_URL)) - options.apiBaseUrl = process.env.OPENAI_API_BASE_URL + if (isNotEmptyString(OPENAI_API_BASE_URL)) + options.apiBaseUrl = `${OPENAI_API_BASE_URL}/v1` setupProxy(options)