diff --git a/service/package.json b/service/package.json index 4089b9e..d457c7b 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 62e4b03..c702e6a 100644 --- a/service/src/chatgpt/index.ts +++ b/service/src/chatgpt/index.ts @@ -3,7 +3,7 @@ import 'isomorphic-fetch' import type { ChatGPTAPIOptions, ChatMessage, SendMessageOptions } from 'chatgpt' import { ChatGPTAPI, ChatGPTUnofficialProxyAPI } from 'chatgpt' import { SocksProxyAgent } from 'socks-proxy-agent' -import { HttpsProxyAgent } from 'https-proxy-agent' +import httpsProxyAgent from 'https-proxy-agent' import fetch from 'node-fetch' import axios from 'axios' import { sendResponse } from '../utils' @@ -11,6 +11,8 @@ import { isNotEmptyString } from '../utils/is' import type { ApiModel, ChatContext, ChatGPTUnofficialProxyAPIOptions, ModelConfig } from '../types' 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 4f24c6a..534f06d 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,