diff --git a/service/package.json b/service/package.json index 4089b9ea09..d457c7b57f 100644 --- a/service/package.json +++ b/service/package.json @@ -16,7 +16,7 @@ "scripts": { "start": "esno ./src/index.ts", "dev": "esno watch ./src/index.ts", - "prod": "esno ./build/index.js", + "prod": "node ./build/index.mjs", "build": "pnpm clean && tsup", "clean": "rimraf build", "lint": "eslint .", diff --git a/service/src/chatgpt/index.ts b/service/src/chatgpt/index.ts index 4c4b672feb..d38436a30f 100644 --- a/service/src/chatgpt/index.ts +++ b/service/src/chatgpt/index.ts @@ -1,13 +1,16 @@ import axios from 'axios' import type { ChatGPTAPIOptions, ChatMessage, SendMessageOptions } from 'chatgpt' import { ChatGPTAPI, ChatGPTUnofficialProxyAPI } from 'chatgpt' -import { HttpsProxyAgent } from 'https-proxy-agent' +import httpsProxyAgent from 'https-proxy-agent' import fetch from 'node-fetch' +import { SocksProxyAgent } from 'socks-proxy-agent' import type { ApiModel, ChatContext, ChatGPTUnofficialProxyAPIOptions, ModelConfig } from '../types' import { sendResponse } from '../utils' import { isNotEmptyString } from '../utils/is' import type { RequestOptions } from './types' +const { HttpsProxyAgent } = httpsProxyAgent + dotenv.config() const ErrorCodeMessage: Record = { diff --git a/service/tsup.config.ts b/service/tsup.config.ts index 4f24c6a19f..534f06df67 100644 --- a/service/tsup.config.ts +++ b/service/tsup.config.ts @@ -4,7 +4,7 @@ export default defineConfig({ entry: ['src/index.ts'], outDir: 'build', target: 'es2020', - format: ['cjs'], + format: ['esm'], splitting: false, sourcemap: true, minify: false,