Merge pull request #347 from Chanzhaoyu/refactor

chore: version 2.9.3
This commit is contained in:
Redon 2023-03-06 20:44:43 +08:00 committed by GitHub
commit dea74e242e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 150 additions and 161 deletions

View File

@ -1,3 +1,17 @@
## v2.9.3
`2023-03-06`
## Enhancement
- 感谢 [ChandlerVer5](https://github.com/Chanzhaoyu/chatgpt-web/pull/305) 使用 `markdown-it` 替换 `marked`,解决代码块闪烁的问题
- 感谢 [shansing](https://github.com/Chanzhaoyu/chatgpt-web/pull/277) 改善文档
- 感谢 [nalf3in](https://github.com/Chanzhaoyu/chatgpt-web/pull/293) 添加英文翻译
## BugFix
- 感谢[sepcnt ](https://github.com/Chanzhaoyu/chatgpt-web/pull/279) 修复切换记录时编辑状态未关闭的问题
- 修复复制代码的兼容性报错问题
- 修复部分优化小问题
## v2.9.2
`2023-03-04`

View File

@ -2,7 +2,7 @@
<div style="font-size: 1.5rem;">
<a href="./README.md">中文</a> |
<a href="./README.en.md">English</a>
<a href="./README.en.md">English</a>
</div>
</br>
@ -27,16 +27,16 @@
- [Packaging](#packaging)
- [Using Docker](#using-docker)
- [Docker Parameter Example](#docker-parameter-example)
- [Docker Build & Run](#docker-build--run)
- [Docker Build \& Run](#docker-build--run)
- [Docker Compose](#docker-compose)
- [Deploying with Railway](#deploying-with-railway)
- [Deployment with Railway](#deployment-with-railway)
- [Railway Environment Variables](#railway-environment-variables)
- [Manual Packaging](#manual-packaging)
- [Backend Service](#backend-service-1)
- [Frontend Webpage](#frontend-webpage-1)
- [FAQ](#faq)
- [Manual packaging](#manual-packaging)
- [Backend service](#backend-service-1)
- [Frontend webpage](#frontend-webpage-1)
- [Frequently Asked Questions](#frequently-asked-questions)
- [Contributing](#contributing)
- [Sponsor](#sponsor)
- [Sponsorship](#sponsorship)
- [License](#license)
## Introduction
@ -62,7 +62,7 @@ Switching Methods:
Reverse Proxy:
Available when using `ChatGPTUnofficialProxyAPI`.
Available when using `ChatGPTUnofficialProxyAPI`.[Details](https://github.com/transitive-bullshit/chatgpt-api#reverse-proxy)
```shell
# service/.env
@ -309,4 +309,4 @@ If you find this project helpful and circumstances permit, you can give me a lit
</div>
## License
MIT © [ChenZhaoYu](./license)
MIT © [ChenZhaoYu](./license)

View File

@ -2,7 +2,7 @@
<div style="font-size: 1.5rem;">
<a href="./README.md">中文</a> |
<a href="./README.en.md">English</a>
<a href="./README.en.md">English</a>
</div>
</br>
@ -61,7 +61,7 @@
反向代理:
`ChatGPTUnofficialProxyAPI`时可用
`ChatGPTUnofficialProxyAPI`时可用[详情](https://github.com/transitive-bullshit/chatgpt-api#reverse-proxy)
```shell
# service/.env

View File

@ -1,6 +1,6 @@
{
"name": "chatgpt-web",
"version": "2.9.2",
"version": "2.9.3",
"private": false,
"description": "ChatGPT Web",
"author": "ChenZhaoYu <chenzhaoyu1994@gmail.com>",

View File

@ -24,7 +24,7 @@
"common:cleanup": "rimraf node_modules && rimraf pnpm-lock.yaml"
},
"dependencies": {
"chatgpt": "^5.0.6",
"chatgpt": "^5.0.7",
"dotenv": "^16.0.3",
"esno": "^0.16.3",
"express": "^4.18.2",
@ -37,7 +37,7 @@
"@types/express": "^4.17.17",
"@types/node": "^18.14.6",
"eslint": "^8.35.0",
"rimraf": "^4.2.0",
"rimraf": "^4.3.0",
"tsup": "^6.6.3",
"typescript": "^4.9.5"
}

View File

@ -4,20 +4,20 @@ specifiers:
'@antfu/eslint-config': ^0.35.3
'@types/express': ^4.17.17
'@types/node': ^18.14.6
chatgpt: ^5.0.6
chatgpt: ^5.0.7
dotenv: ^16.0.3
eslint: ^8.35.0
esno: ^0.16.3
express: ^4.18.2
isomorphic-fetch: ^3.0.0
node-fetch: ^3.3.0
rimraf: ^4.2.0
rimraf: ^4.3.0
socks-proxy-agent: ^7.0.0
tsup: ^6.6.3
typescript: ^4.9.5
dependencies:
chatgpt: 5.0.6
chatgpt: 5.0.7
dotenv: 16.0.3
esno: 0.16.3
express: 4.18.2
@ -30,7 +30,7 @@ devDependencies:
'@types/express': 4.17.17
'@types/node': 18.14.6
eslint: 8.35.0
rimraf: 4.2.0
rimraf: 4.3.0
tsup: 6.6.3_typescript@4.9.5
typescript: 4.9.5
@ -164,7 +164,7 @@ packages:
/@esbuild-kit/core-utils/3.1.0:
resolution: {integrity: sha512-Uuk8RpCg/7fdHSceR1M6XbSZFSuMrxcePFuGgyvsBn+u339dk5OeL4jv2EojwTN2st/unJGsVm4qHWjWNmJ/tw==}
dependencies:
esbuild: 0.17.8
esbuild: 0.17.11
source-map-support: 0.5.21
dev: false
@ -175,187 +175,187 @@ packages:
get-tsconfig: 4.4.0
dev: false
/@esbuild/android-arm/0.17.8:
resolution: {integrity: sha512-0/rb91GYKhrtbeglJXOhAv9RuYimgI8h623TplY2X+vA4EXnk3Zj1fXZreJ0J3OJJu1bwmb0W7g+2cT/d8/l/w==}
/@esbuild/android-arm/0.17.11:
resolution: {integrity: sha512-CdyX6sRVh1NzFCsf5vw3kULwlAhfy9wVt8SZlrhQ7eL2qBjGbFhRBWkkAzuZm9IIEOCKJw4DXA6R85g+qc8RDw==}
engines: {node: '>=12'}
cpu: [arm]
os: [android]
requiresBuild: true
optional: true
/@esbuild/android-arm64/0.17.8:
resolution: {integrity: sha512-oa/N5j6v1svZQs7EIRPqR8f+Bf8g6HBDjD/xHC02radE/NjKHK7oQmtmLxPs1iVwYyvE+Kolo6lbpfEQ9xnhxQ==}
/@esbuild/android-arm64/0.17.11:
resolution: {integrity: sha512-QnK4d/zhVTuV4/pRM4HUjcsbl43POALU2zvBynmrrqZt9LPcLA3x1fTZPBg2RRguBQnJcnU059yKr+bydkntjg==}
engines: {node: '>=12'}
cpu: [arm64]
os: [android]
requiresBuild: true
optional: true
/@esbuild/android-x64/0.17.8:
resolution: {integrity: sha512-bTliMLqD7pTOoPg4zZkXqCDuzIUguEWLpeqkNfC41ODBHwoUgZ2w5JBeYimv4oP6TDVocoYmEhZrCLQTrH89bg==}
/@esbuild/android-x64/0.17.11:
resolution: {integrity: sha512-3PL3HKtsDIXGQcSCKtWD/dy+mgc4p2Tvo2qKgKHj9Yf+eniwFnuoQ0OUhlSfAEpKAFzF9N21Nwgnap6zy3L3MQ==}
engines: {node: '>=12'}
cpu: [x64]
os: [android]
requiresBuild: true
optional: true
/@esbuild/darwin-arm64/0.17.8:
resolution: {integrity: sha512-ghAbV3ia2zybEefXRRm7+lx8J/rnupZT0gp9CaGy/3iolEXkJ6LYRq4IpQVI9zR97ID80KJVoUlo3LSeA/sMAg==}
/@esbuild/darwin-arm64/0.17.11:
resolution: {integrity: sha512-pJ950bNKgzhkGNO3Z9TeHzIFtEyC2GDQL3wxkMApDEghYx5Qers84UTNc1bAxWbRkuJOgmOha5V0WUeh8G+YGw==}
engines: {node: '>=12'}
cpu: [arm64]
os: [darwin]
requiresBuild: true
optional: true
/@esbuild/darwin-x64/0.17.8:
resolution: {integrity: sha512-n5WOpyvZ9TIdv2V1K3/iIkkJeKmUpKaCTdun9buhGRWfH//osmUjlv4Z5mmWdPWind/VGcVxTHtLfLCOohsOXw==}
/@esbuild/darwin-x64/0.17.11:
resolution: {integrity: sha512-iB0dQkIHXyczK3BZtzw1tqegf0F0Ab5texX2TvMQjiJIWXAfM4FQl7D909YfXWnB92OQz4ivBYQ2RlxBJrMJOw==}
engines: {node: '>=12'}
cpu: [x64]
os: [darwin]
requiresBuild: true
optional: true
/@esbuild/freebsd-arm64/0.17.8:
resolution: {integrity: sha512-a/SATTaOhPIPFWvHZDoZYgxaZRVHn0/LX1fHLGfZ6C13JqFUZ3K6SMD6/HCtwOQ8HnsNaEeokdiDSFLuizqv5A==}
/@esbuild/freebsd-arm64/0.17.11:
resolution: {integrity: sha512-7EFzUADmI1jCHeDRGKgbnF5sDIceZsQGapoO6dmw7r/ZBEKX7CCDnIz8m9yEclzr7mFsd+DyasHzpjfJnmBB1Q==}
engines: {node: '>=12'}
cpu: [arm64]
os: [freebsd]
requiresBuild: true
optional: true
/@esbuild/freebsd-x64/0.17.8:
resolution: {integrity: sha512-xpFJb08dfXr5+rZc4E+ooZmayBW6R3q59daCpKZ/cDU96/kvDM+vkYzNeTJCGd8rtO6fHWMq5Rcv/1cY6p6/0Q==}
/@esbuild/freebsd-x64/0.17.11:
resolution: {integrity: sha512-iPgenptC8i8pdvkHQvXJFzc1eVMR7W2lBPrTE6GbhR54sLcF42mk3zBOjKPOodezzuAz/KSu8CPyFSjcBMkE9g==}
engines: {node: '>=12'}
cpu: [x64]
os: [freebsd]
requiresBuild: true
optional: true
/@esbuild/linux-arm/0.17.8:
resolution: {integrity: sha512-6Ij8gfuGszcEwZpi5jQIJCVIACLS8Tz2chnEBfYjlmMzVsfqBP1iGmHQPp7JSnZg5xxK9tjCc+pJ2WtAmPRFVA==}
/@esbuild/linux-arm/0.17.11:
resolution: {integrity: sha512-M9iK/d4lgZH0U5M1R2p2gqhPV/7JPJcRz+8O8GBKVgqndTzydQ7B2XGDbxtbvFkvIs53uXTobOhv+RyaqhUiMg==}
engines: {node: '>=12'}
cpu: [arm]
os: [linux]
requiresBuild: true
optional: true
/@esbuild/linux-arm64/0.17.8:
resolution: {integrity: sha512-v3iwDQuDljLTxpsqQDl3fl/yihjPAyOguxuloON9kFHYwopeJEf1BkDXODzYyXEI19gisEsQlG1bM65YqKSIww==}
/@esbuild/linux-arm64/0.17.11:
resolution: {integrity: sha512-Qxth3gsWWGKz2/qG2d5DsW/57SeA2AmpSMhdg9TSB5Svn2KDob3qxfQSkdnWjSd42kqoxIPy3EJFs+6w1+6Qjg==}
engines: {node: '>=12'}
cpu: [arm64]
os: [linux]
requiresBuild: true
optional: true
/@esbuild/linux-ia32/0.17.8:
resolution: {integrity: sha512-8svILYKhE5XetuFk/B6raFYIyIqydQi+GngEXJgdPdI7OMKUbSd7uzR02wSY4kb53xBrClLkhH4Xs8P61Q2BaA==}
/@esbuild/linux-ia32/0.17.11:
resolution: {integrity: sha512-dB1nGaVWtUlb/rRDHmuDQhfqazWE0LMro/AIbT2lWM3CDMHJNpLckH+gCddQyhhcLac2OYw69ikUMO34JLt3wA==}
engines: {node: '>=12'}
cpu: [ia32]
os: [linux]
requiresBuild: true
optional: true
/@esbuild/linux-loong64/0.17.8:
resolution: {integrity: sha512-B6FyMeRJeV0NpyEOYlm5qtQfxbdlgmiGdD+QsipzKfFky0K5HW5Td6dyK3L3ypu1eY4kOmo7wW0o94SBqlqBSA==}
/@esbuild/linux-loong64/0.17.11:
resolution: {integrity: sha512-aCWlq70Q7Nc9WDnormntGS1ar6ZFvUpqr8gXtO+HRejRYPweAFQN615PcgaSJkZjhHp61+MNLhzyVALSF2/Q0g==}
engines: {node: '>=12'}
cpu: [loong64]
os: [linux]
requiresBuild: true
optional: true
/@esbuild/linux-mips64el/0.17.8:
resolution: {integrity: sha512-CCb67RKahNobjm/eeEqeD/oJfJlrWyw29fgiyB6vcgyq97YAf3gCOuP6qMShYSPXgnlZe/i4a8WFHBw6N8bYAA==}
/@esbuild/linux-mips64el/0.17.11:
resolution: {integrity: sha512-cGeGNdQxqY8qJwlYH1BP6rjIIiEcrM05H7k3tR7WxOLmD1ZxRMd6/QIOWMb8mD2s2YJFNRuNQ+wjMhgEL2oCEw==}
engines: {node: '>=12'}
cpu: [mips64el]
os: [linux]
requiresBuild: true
optional: true
/@esbuild/linux-ppc64/0.17.8:
resolution: {integrity: sha512-bytLJOi55y55+mGSdgwZ5qBm0K9WOCh0rx+vavVPx+gqLLhxtSFU0XbeYy/dsAAD6xECGEv4IQeFILaSS2auXw==}
/@esbuild/linux-ppc64/0.17.11:
resolution: {integrity: sha512-BdlziJQPW/bNe0E8eYsHB40mYOluS+jULPCjlWiHzDgr+ZBRXPtgMV1nkLEGdpjrwgmtkZHEGEPaKdS/8faLDA==}
engines: {node: '>=12'}
cpu: [ppc64]
os: [linux]
requiresBuild: true
optional: true
/@esbuild/linux-riscv64/0.17.8:
resolution: {integrity: sha512-2YpRyQJmKVBEHSBLa8kBAtbhucaclb6ex4wchfY0Tj3Kg39kpjeJ9vhRU7x4mUpq8ISLXRXH1L0dBYjAeqzZAw==}
/@esbuild/linux-riscv64/0.17.11:
resolution: {integrity: sha512-MDLwQbtF+83oJCI1Cixn68Et/ME6gelmhssPebC40RdJaect+IM+l7o/CuG0ZlDs6tZTEIoxUe53H3GmMn8oMA==}
engines: {node: '>=12'}
cpu: [riscv64]
os: [linux]
requiresBuild: true
optional: true
/@esbuild/linux-s390x/0.17.8:
resolution: {integrity: sha512-QgbNY/V3IFXvNf11SS6exkpVcX0LJcob+0RWCgV9OiDAmVElnxciHIisoSix9uzYzScPmS6dJFbZULdSAEkQVw==}
/@esbuild/linux-s390x/0.17.11:
resolution: {integrity: sha512-4N5EMESvws0Ozr2J94VoUD8HIRi7X0uvUv4c0wpTHZyZY9qpaaN7THjosdiW56irQ4qnJ6Lsc+i+5zGWnyqWqQ==}
engines: {node: '>=12'}
cpu: [s390x]
os: [linux]
requiresBuild: true
optional: true
/@esbuild/linux-x64/0.17.8:
resolution: {integrity: sha512-mM/9S0SbAFDBc4OPoyP6SEOo5324LpUxdpeIUUSrSTOfhHU9hEfqRngmKgqILqwx/0DVJBzeNW7HmLEWp9vcOA==}
/@esbuild/linux-x64/0.17.11:
resolution: {integrity: sha512-rM/v8UlluxpytFSmVdbCe1yyKQd/e+FmIJE2oPJvbBo+D0XVWi1y/NQ4iTNx+436WmDHQBjVLrbnAQLQ6U7wlw==}
engines: {node: '>=12'}
cpu: [x64]
os: [linux]
requiresBuild: true
optional: true
/@esbuild/netbsd-x64/0.17.8:
resolution: {integrity: sha512-eKUYcWaWTaYr9zbj8GertdVtlt1DTS1gNBWov+iQfWuWyuu59YN6gSEJvFzC5ESJ4kMcKR0uqWThKUn5o8We6Q==}
/@esbuild/netbsd-x64/0.17.11:
resolution: {integrity: sha512-4WaAhuz5f91h3/g43VBGdto1Q+X7VEZfpcWGtOFXnggEuLvjV+cP6DyLRU15IjiU9fKLLk41OoJfBFN5DhPvag==}
engines: {node: '>=12'}
cpu: [x64]
os: [netbsd]
requiresBuild: true
optional: true
/@esbuild/openbsd-x64/0.17.8:
resolution: {integrity: sha512-Vc9J4dXOboDyMXKD0eCeW0SIeEzr8K9oTHJU+Ci1mZc5njPfhKAqkRt3B/fUNU7dP+mRyralPu8QUkiaQn7iIg==}
/@esbuild/openbsd-x64/0.17.11:
resolution: {integrity: sha512-UBj135Nx4FpnvtE+C8TWGp98oUgBcmNmdYgl5ToKc0mBHxVVqVE7FUS5/ELMImOp205qDAittL6Ezhasc2Ev/w==}
engines: {node: '>=12'}
cpu: [x64]
os: [openbsd]
requiresBuild: true
optional: true
/@esbuild/sunos-x64/0.17.8:
resolution: {integrity: sha512-0xvOTNuPXI7ft1LYUgiaXtpCEjp90RuBBYovdd2lqAFxje4sEucurg30M1WIm03+3jxByd3mfo+VUmPtRSVuOw==}
/@esbuild/sunos-x64/0.17.11:
resolution: {integrity: sha512-1/gxTifDC9aXbV2xOfCbOceh5AlIidUrPsMpivgzo8P8zUtczlq1ncFpeN1ZyQJ9lVs2hILy1PG5KPp+w8QPPg==}
engines: {node: '>=12'}
cpu: [x64]
os: [sunos]
requiresBuild: true
optional: true
/@esbuild/win32-arm64/0.17.8:
resolution: {integrity: sha512-G0JQwUI5WdEFEnYNKzklxtBheCPkuDdu1YrtRrjuQv30WsYbkkoixKxLLv8qhJmNI+ATEWquZe/N0d0rpr55Mg==}
/@esbuild/win32-arm64/0.17.11:
resolution: {integrity: sha512-vtSfyx5yRdpiOW9yp6Ax0zyNOv9HjOAw8WaZg3dF5djEHKKm3UnoohftVvIJtRh0Ec7Hso0RIdTqZvPXJ7FdvQ==}
engines: {node: '>=12'}
cpu: [arm64]
os: [win32]
requiresBuild: true
optional: true
/@esbuild/win32-ia32/0.17.8:
resolution: {integrity: sha512-Fqy63515xl20OHGFykjJsMnoIWS+38fqfg88ClvPXyDbLtgXal2DTlhb1TfTX34qWi3u4I7Cq563QcHpqgLx8w==}
/@esbuild/win32-ia32/0.17.11:
resolution: {integrity: sha512-GFPSLEGQr4wHFTiIUJQrnJKZhZjjq4Sphf+mM76nQR6WkQn73vm7IsacmBRPkALfpOCHsopSvLgqdd4iUW2mYw==}
engines: {node: '>=12'}
cpu: [ia32]
os: [win32]
requiresBuild: true
optional: true
/@esbuild/win32-x64/0.17.8:
resolution: {integrity: sha512-1iuezdyDNngPnz8rLRDO2C/ZZ/emJLb72OsZeqQ6gL6Avko/XCXZw+NuxBSNhBAP13Hie418V7VMt9et1FMvpg==}
/@esbuild/win32-x64/0.17.11:
resolution: {integrity: sha512-N9vXqLP3eRL8BqSy8yn4Y98cZI2pZ8fyuHx6lKjiG2WABpT2l01TXdzq5Ma2ZUBzfB7tx5dXVhge8X9u0S70ZQ==}
engines: {node: '>=12'}
cpu: [x64]
os: [win32]
requiresBuild: true
optional: true
/@eslint-community/eslint-utils/4.1.2_eslint@8.35.0:
resolution: {integrity: sha512-7qELuQWWjVDdVsFQ5+beUl+KPczrEDA7S3zM4QUd/bJl7oXgsmpXaEVqrRTnOBqenOV4rWf2kVZk2Ot085zPWA==}
/@eslint-community/eslint-utils/4.2.0_eslint@8.35.0:
resolution: {integrity: sha512-gB8T4H4DEfX2IV9zGDJPOBgP1e/DbfCPDTtEqUMckpvzS1OYtva8JdFYBqMwYk7xAQ429WGF/UPqn8uQ//h2vQ==}
engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0}
peerDependencies:
eslint: ^6.0.0 || ^7.0.0 || ^8.0.0
eslint: ^6.0.0 || ^7.0.0 || >=8.0.0
dependencies:
eslint: 8.35.0
eslint-visitor-keys: 3.3.0
@ -451,7 +451,7 @@ packages:
'@types/body-parser': 1.19.2
'@types/express-serve-static-core': 4.17.33
'@types/qs': 6.9.7
'@types/serve-static': 1.15.0
'@types/serve-static': 1.15.1
dev: true
/@types/json-schema/7.0.11:
@ -491,8 +491,8 @@ packages:
resolution: {integrity: sha512-21cFJr9z3g5dW8B0CVI9g2O9beqaThGQ6ZFBqHfwhzLDKUxaqTIy3vnfah/UPkfOiF2pLq+tGz+W8RyCskuslw==}
dev: true
/@types/serve-static/1.15.0:
resolution: {integrity: sha512-z5xyF6uh8CbjAu9760KDKsH2FcDxZ2tFCsA4HIMWE6IkiYMXfVoa+4f9KX+FN0ZLsaMw1WNG2ETLA6N+/YA+cg==}
/@types/serve-static/1.15.1:
resolution: {integrity: sha512-NUo5XNiAdULrJENtJXZZ3fHtfMolzZwczzBbnAeBbqBwG+LaG6YaJtuwzwGSQZ2wsCrxjEhNNjAkKigy3n8teQ==}
dependencies:
'@types/mime': 3.0.1
'@types/node': 18.14.6
@ -844,13 +844,13 @@ packages:
semver: 7.3.8
dev: true
/bundle-require/4.0.1_esbuild@0.17.8:
/bundle-require/4.0.1_esbuild@0.17.11:
resolution: {integrity: sha512-9NQkRHlNdNpDBGmLpngF3EFDcwodhMUuLz9PaWYciVcQF9SE4LFjM2DB/xV1Li5JiuDMv7ZUWuC3rGbqR0MAXQ==}
engines: {node: ^12.20.0 || ^14.13.1 || >=16.0.0}
peerDependencies:
esbuild: '>=0.17'
dependencies:
esbuild: 0.17.8
esbuild: 0.17.11
load-tsconfig: 0.2.3
dev: true
@ -902,8 +902,8 @@ packages:
resolution: {integrity: sha512-mKKUkUbhPpQlCOfIuZkvSEgktjPFIsZKRRbC6KWVEMvlzblj3i3asQv5ODsrwt0N3pHAEvjP8KTQPHkp0+6jOg==}
dev: true
/chatgpt/5.0.6:
resolution: {integrity: sha512-BQ0eN2GpAlw9ojsxkHmW+bTuekbllZbOkKqjDSIVSMtbMoYDx59vcg6xXnCPkB0OBFGuG89eqGhLAfMIW34Hcw==}
/chatgpt/5.0.7:
resolution: {integrity: sha512-wy69++JDNS0xKi+6rP+HDOByXBafQIVynHnlQw09apuDntGSKfwBRY902N8Q7/ZFU/XET+8NpJiio2iI69IWYw==}
engines: {node: '>=14'}
hasBin: true
dependencies:
@ -1193,7 +1193,7 @@ packages:
has-proto: 1.0.1
has-symbols: 1.0.3
internal-slot: 1.0.5
is-array-buffer: 3.0.1
is-array-buffer: 3.0.2
is-callable: 1.2.7
is-negative-zero: 2.0.2
is-regex: 1.1.4
@ -1237,34 +1237,34 @@ packages:
is-symbol: 1.0.4
dev: true
/esbuild/0.17.8:
resolution: {integrity: sha512-g24ybC3fWhZddZK6R3uD2iF/RIPnRpwJAqLov6ouX3hMbY4+tKolP0VMF3zuIYCaXun+yHwS5IPQ91N2BT191g==}
/esbuild/0.17.11:
resolution: {integrity: sha512-pAMImyokbWDtnA/ufPxjQg0fYo2DDuzAlqwnDvbXqHLphe+m80eF++perYKVm8LeTuj2zUuFXC+xgSVxyoHUdg==}
engines: {node: '>=12'}
hasBin: true
requiresBuild: true
optionalDependencies:
'@esbuild/android-arm': 0.17.8
'@esbuild/android-arm64': 0.17.8
'@esbuild/android-x64': 0.17.8
'@esbuild/darwin-arm64': 0.17.8
'@esbuild/darwin-x64': 0.17.8
'@esbuild/freebsd-arm64': 0.17.8
'@esbuild/freebsd-x64': 0.17.8
'@esbuild/linux-arm': 0.17.8
'@esbuild/linux-arm64': 0.17.8
'@esbuild/linux-ia32': 0.17.8
'@esbuild/linux-loong64': 0.17.8
'@esbuild/linux-mips64el': 0.17.8
'@esbuild/linux-ppc64': 0.17.8
'@esbuild/linux-riscv64': 0.17.8
'@esbuild/linux-s390x': 0.17.8
'@esbuild/linux-x64': 0.17.8
'@esbuild/netbsd-x64': 0.17.8
'@esbuild/openbsd-x64': 0.17.8
'@esbuild/sunos-x64': 0.17.8
'@esbuild/win32-arm64': 0.17.8
'@esbuild/win32-ia32': 0.17.8
'@esbuild/win32-x64': 0.17.8
'@esbuild/android-arm': 0.17.11
'@esbuild/android-arm64': 0.17.11
'@esbuild/android-x64': 0.17.11
'@esbuild/darwin-arm64': 0.17.11
'@esbuild/darwin-x64': 0.17.11
'@esbuild/freebsd-arm64': 0.17.11
'@esbuild/freebsd-x64': 0.17.11
'@esbuild/linux-arm': 0.17.11
'@esbuild/linux-arm64': 0.17.11
'@esbuild/linux-ia32': 0.17.11
'@esbuild/linux-loong64': 0.17.11
'@esbuild/linux-mips64el': 0.17.11
'@esbuild/linux-ppc64': 0.17.11
'@esbuild/linux-riscv64': 0.17.11
'@esbuild/linux-s390x': 0.17.11
'@esbuild/linux-x64': 0.17.11
'@esbuild/netbsd-x64': 0.17.11
'@esbuild/openbsd-x64': 0.17.11
'@esbuild/sunos-x64': 0.17.11
'@esbuild/win32-arm64': 0.17.11
'@esbuild/win32-ia32': 0.17.11
'@esbuild/win32-x64': 0.17.11
/escape-html/1.0.3:
resolution: {integrity: sha512-NiSupZ4OeuGwr68lGIeym/ksIZMJodUGOSCZ/FSnTxcrekbvqrgdUxlJOMpijaKZVjAJrWrGs/6Jy8OMuyj9ow==}
@ -1382,7 +1382,7 @@ packages:
object.values: 1.1.6
resolve: 1.22.1
semver: 6.3.0
tsconfig-paths: 3.14.1
tsconfig-paths: 3.14.2
transitivePeerDependencies:
- eslint-import-resolver-typescript
- eslint-import-resolver-webpack
@ -1472,11 +1472,11 @@ packages:
eslint: '>=8.28.0'
dependencies:
'@babel/helper-validator-identifier': 7.19.1
'@eslint-community/eslint-utils': 4.1.2_eslint@8.35.0
'@eslint-community/eslint-utils': 4.2.0_eslint@8.35.0
ci-info: 3.8.0
clean-regexp: 1.0.0
eslint: 8.35.0
esquery: 1.4.2
esquery: 1.5.0
indent-string: 4.0.0
is-builtin-module: 3.2.1
jsesc: 3.0.2
@ -1611,7 +1611,7 @@ packages:
eslint-utils: 3.0.0_eslint@8.35.0
eslint-visitor-keys: 3.3.0
espree: 9.4.1
esquery: 1.4.2
esquery: 1.5.0
esutils: 2.0.3
fast-deep-equal: 3.1.3
file-entry-cache: 6.0.1
@ -1656,8 +1656,8 @@ packages:
eslint-visitor-keys: 3.3.0
dev: true
/esquery/1.4.2:
resolution: {integrity: sha512-JVSoLdTlTDkmjFmab7H/9SL9qGSyjElT3myyKp7krqjVFQCDLmj1QFaCLRFBszBKI0XVZaiiXvuPIX3ZwHe1Ng==}
/esquery/1.5.0:
resolution: {integrity: sha512-YQLXUplAwJgCydQ78IMJywZCceoqk1oH01OERdSAJc/7U2AylwjhSCLDEtqwg811idIS/9fIU5GjG73IgjKMVg==}
engines: {node: '>=0.10'}
dependencies:
estraverse: 5.3.0
@ -2153,8 +2153,8 @@ packages:
is-decimal: 1.0.4
dev: true
/is-array-buffer/3.0.1:
resolution: {integrity: sha512-ASfLknmY8Xa2XtB4wmbz13Wu202baeA18cJBCeCy0wXUHZF0IPyVEXqKEcd+t2fNSLLL1vC6k7lxZEojNbISXQ==}
/is-array-buffer/3.0.2:
resolution: {integrity: sha512-y+FyyR/w8vfIRq4eQcM1EYgSTnmHXPqaF+IgzgraytCFq5Xh8lllDVmAZolPJiZttZLeFSINPYMaEJ7/vWUa1w==}
dependencies:
call-bind: 1.0.2
get-intrinsic: 1.2.0
@ -2398,8 +2398,8 @@ packages:
type-check: 0.4.0
dev: true
/lilconfig/2.0.6:
resolution: {integrity: sha512-9JROoBW7pobfsx+Sq2JsASvCo6Pfo6WWoUW79HuB1BCoBXD4PLWJPqDF6fNj67pqBYTbAHkE57M1kS/+L1neOg==}
/lilconfig/2.1.0:
resolution: {integrity: sha512-utWOt/GHzuUxnLKxB6dk81RoOeoNeHgbrXiuGk4yyF5qlRz+iIVWu56E2fqGHFrXz0QNUhLB/8nKqvRH66JKGQ==}
engines: {node: '>=10'}
dev: true
@ -2455,8 +2455,8 @@ packages:
dependencies:
yallist: 4.0.0
/lru-cache/7.18.1:
resolution: {integrity: sha512-8/HcIENyQnfUTCDizRu9rrDyG6XG/21M4X7/YEGZeD76ZJilFPAUVb/2zysFf7VVO1LEjCDFyHp8pMMvozIrvg==}
/lru-cache/7.18.3:
resolution: {integrity: sha512-jumlc0BIUrS3qJGgIkWZsyfAM7NCWiBcCDhnd+3NNM5KbBmLTgHVfWBcg6W+rLUsIpzpERPsvwUP7CckAQSOoA==}
engines: {node: '>=12'}
dev: true
@ -2841,7 +2841,7 @@ packages:
resolution: {integrity: sha512-OW+5s+7cw6253Q4E+8qQ/u1fVvcJQCJo/VFD8pje+dbJCF1n5ZRMV2AEHbGp+5Q7jxQIYJxkHopnj6nzdGeZLA==}
engines: {node: '>=14'}
dependencies:
lru-cache: 7.18.1
lru-cache: 7.18.3
minipass: 4.2.4
dev: true
@ -2881,7 +2881,7 @@ packages:
ts-node:
optional: true
dependencies:
lilconfig: 2.0.6
lilconfig: 2.1.0
yaml: 1.10.2
dev: true
@ -3048,16 +3048,16 @@ packages:
glob: 7.2.3
dev: true
/rimraf/4.2.0:
resolution: {integrity: sha512-tPt+gLORNVqRCk0NwuJ5SlMEcOGvt4CCU8sUPqgCFtCbnoNCTd9Q6vq7JlBbxQlACiH14OR28y7piA2Bak9Sxw==}
/rimraf/4.3.0:
resolution: {integrity: sha512-5qVDXPbByA1qSJEWMv1qAwKsoS22vVpsL2QyxCKBw4gf6XiFo1K3uRLY6uSOOBFDwnqAZtnbILqWKKlzh8bkGg==}
engines: {node: '>=14'}
hasBin: true
dependencies:
glob: 9.2.1
dev: true
/rollup/3.15.0:
resolution: {integrity: sha512-F9hrCAhnp5/zx/7HYmftvsNBkMfLfk/dXUh73hPSM2E3CRgap65orDNJbLetoiUFwSAk6iHPLvBrZ5iHYvzqsg==}
/rollup/3.18.0:
resolution: {integrity: sha512-J8C6VfEBjkvYPESMQYxKHxNOh4A5a3FlP+0BETGo34HEcE4eTlgCrO2+eWzlu2a/sHs2QUkZco+wscH7jhhgWg==}
engines: {node: '>=14.18.0', npm: '>=8.0.0'}
hasBin: true
optionalDependencies:
@ -3368,8 +3368,8 @@ packages:
resolution: {integrity: sha512-Y/arvbn+rrz3JCKl9C4kVNfTfSm2/mEp5FSz5EsZSANGPSlQrpRI5M4PKF+mJnE52jOO90PnPSc3Ur3bTQw0gA==}
dev: true
/tsconfig-paths/3.14.1:
resolution: {integrity: sha512-fxDhWnFSLt3VuTwtvJt5fpwxBHg5AdKWMsgcPOOIilyjymcYVZoCQF8fvFRezCNfblEXmi+PcM1eYHeOAgXCOQ==}
/tsconfig-paths/3.14.2:
resolution: {integrity: sha512-o/9iXgCYc5L/JxCHPe3Hvh8Q/2xm5Z+p18PESBU6Ff33695QnCHBEjcytY2q19ua7Mbl/DavtBOLq+oG0RCL+g==}
dependencies:
'@types/json5': 0.0.29
json5: 1.0.2
@ -3397,17 +3397,17 @@ packages:
typescript:
optional: true
dependencies:
bundle-require: 4.0.1_esbuild@0.17.8
bundle-require: 4.0.1_esbuild@0.17.11
cac: 6.7.14
chokidar: 3.5.3
debug: 4.3.4
esbuild: 0.17.8
esbuild: 0.17.11
execa: 5.1.1
globby: 11.1.0
joycon: 3.1.1
postcss-load-config: 3.1.4
resolve-from: 5.0.0
rollup: 3.15.0
rollup: 3.18.0
source-map: 0.8.0-beta.0
sucrase: 3.29.0
tree-kill: 1.2.2
@ -3548,7 +3548,7 @@ packages:
eslint-scope: 7.1.1
eslint-visitor-keys: 3.3.0
espree: 9.4.1
esquery: 1.4.2
esquery: 1.5.0
lodash: 4.17.21
semver: 7.3.8
transitivePeerDependencies:

View File

@ -24,6 +24,9 @@ let api: ChatGPTAPI | ChatGPTUnofficialProxyAPI
if (process.env.OPENAI_API_KEY) {
const options: ChatGPTAPIOptions = {
apiKey: process.env.OPENAI_API_KEY,
completionParams: {
model: 'gpt-3.5-turbo',
},
debug: false,
}
@ -67,28 +70,6 @@ let api: ChatGPTAPI | ChatGPTUnofficialProxyAPI
}
})()
async function chatReply(
message: string,
lastContext?: { conversationId?: string; parentMessageId?: string },
) {
if (!message)
return sendResponse({ type: 'Fail', message: 'Message is empty' })
try {
let options: SendMessageOptions = { timeoutMs }
if (lastContext)
options = { ...lastContext }
const response = await api.sendMessage(message, { ...options })
return sendResponse({ type: 'Success', data: response })
}
catch (error: any) {
return sendResponse({ type: 'Fail', message: error.message })
}
}
async function chatReplyProcess(
message: string,
lastContext?: { conversationId?: string; parentMessageId?: string },
@ -100,8 +81,12 @@ async function chatReplyProcess(
try {
let options: SendMessageOptions = { timeoutMs }
if (lastContext)
options = { ...lastContext }
if (lastContext) {
if (apiModel === 'ChatGPTAPI')
options = { parentMessageId: lastContext.parentMessageId }
else
options = { ...lastContext }
}
const response = await api.sendMessage(message, {
...options,
@ -113,6 +98,7 @@ async function chatReplyProcess(
return sendResponse({ type: 'Success', data: response })
}
catch (error: any) {
global.console.error(error)
return sendResponse({ type: 'Fail', message: error.message })
}
}
@ -131,4 +117,4 @@ async function chatConfig() {
export type { ChatContext, ChatMessage }
export { chatReply, chatReplyProcess, chatConfig }
export { chatReplyProcess, chatConfig }

View File

@ -1,6 +1,6 @@
import express from 'express'
import type { ChatContext, ChatMessage } from './chatgpt'
import { chatConfig, chatReply, chatReplyProcess } from './chatgpt'
import { chatConfig, chatReplyProcess } from './chatgpt'
const app = express()
const router = express.Router()
@ -15,17 +15,6 @@ app.all('*', (_, res, next) => {
next()
})
router.post('/chat', async (req, res) => {
try {
const { prompt, options = {} } = req.body as { prompt: string; options?: ChatContext }
const response = await chatReply(prompt, options)
res.send(response)
}
catch (error) {
res.send(error)
}
})
router.post('/chat-process', async (req, res) => {
res.setHeader('Content-type', 'application/octet-stream')

View File

@ -3,7 +3,7 @@ import { ss } from '@/utils/storage'
const LOCAL_NAME = 'chatStorage'
export function defaultState(): Chat.ChatState {
const uuid = Date.now()
const uuid = 1002
return { active: uuid, history: [{ uuid, title: 'New Chat', isEdit: false }], chat: [{ uuid, data: [] }] }
}