Compare commits
17 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
405aeaa2a5 | ||
|
|
fd28468778 | ||
|
|
4128d319ed | ||
|
|
4a06b3943c | ||
|
|
77cdcb7798 | ||
|
|
ee542a01f7 | ||
|
|
30372c2e70 | ||
|
|
6646695849 | ||
|
|
e9db25a970 | ||
|
|
63f4d7d77c | ||
|
|
20255ddce4 | ||
|
|
bbd8ff773b | ||
|
|
c8518b7789 | ||
|
|
bf015d35f7 | ||
|
|
eab39b7f88 | ||
|
|
981c036542 | ||
|
|
91f51b6338 |
6
.dockerignore
Normal file
6
.dockerignore
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
node_modules
|
||||||
|
Dockerfile
|
||||||
|
.git
|
||||||
|
.husky
|
||||||
|
.github
|
||||||
|
.vscode
|
||||||
37
.github/workflows/build_docker.yml
vendored
Normal file
37
.github/workflows/build_docker.yml
vendored
Normal file
@@ -0,0 +1,37 @@
|
|||||||
|
name: build_docker
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches: [main]
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
build_docker:
|
||||||
|
name: Build docker
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: Checkout
|
||||||
|
uses: actions/checkout@v3
|
||||||
|
- name: Docker meta
|
||||||
|
id: meta
|
||||||
|
uses: docker/metadata-action@v4
|
||||||
|
with:
|
||||||
|
images: chenzhaoyu94/chatgpt-web
|
||||||
|
|
||||||
|
- name: Set up QEMU
|
||||||
|
uses: docker/setup-qemu-action@v2
|
||||||
|
- name: Set up Docker Buildx
|
||||||
|
uses: docker/setup-buildx-action@v2
|
||||||
|
- name: Login to DockerHub
|
||||||
|
uses: docker/login-action@v2
|
||||||
|
with:
|
||||||
|
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
||||||
|
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
||||||
|
- name: Build and push
|
||||||
|
id: docker_build
|
||||||
|
uses: docker/build-push-action@v4
|
||||||
|
with:
|
||||||
|
context: .
|
||||||
|
push: true
|
||||||
|
tags: ${{ steps.meta.outputs.tags }}
|
||||||
|
labels: ${{ steps.meta.outputs.labels }}
|
||||||
|
platforms: linux/amd64,linux/arm64
|
||||||
2
.vscode/settings.json
vendored
2
.vscode/settings.json
vendored
@@ -23,7 +23,9 @@
|
|||||||
"axios",
|
"axios",
|
||||||
"bumpp",
|
"bumpp",
|
||||||
"chatgpt",
|
"chatgpt",
|
||||||
|
"chenzhaoyu",
|
||||||
"commitlint",
|
"commitlint",
|
||||||
|
"dockerhub",
|
||||||
"esno",
|
"esno",
|
||||||
"GPTAPI",
|
"GPTAPI",
|
||||||
"iconify",
|
"iconify",
|
||||||
|
|||||||
20
CHANGELOG.md
20
CHANGELOG.md
@@ -1,3 +1,23 @@
|
|||||||
|
## v2.3.3
|
||||||
|
|
||||||
|
`2023-02-16`
|
||||||
|
|
||||||
|
### Feature
|
||||||
|
- 添加 `README` 部份说明和贡献列表
|
||||||
|
- 添加 `docker` 镜像
|
||||||
|
- 添加 `GitHub Action` 自动化构建
|
||||||
|
|
||||||
|
### BugFix
|
||||||
|
- 回退依赖更新导致的 [Eslint 报错](https://github.com/eslint/eslint/issues/16896)
|
||||||
|
|
||||||
|
## v2.3.2
|
||||||
|
|
||||||
|
`2023-02-16`
|
||||||
|
|
||||||
|
### Enhancement
|
||||||
|
- 更新依赖至最新
|
||||||
|
- 优化部份内容
|
||||||
|
|
||||||
## v2.3.1
|
## v2.3.1
|
||||||
|
|
||||||
`2023-02-15`
|
`2023-02-15`
|
||||||
|
|||||||
20
Dockerfile
Normal file
20
Dockerfile
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
# build front-end
|
||||||
|
FROM node:lts-alpine AS builder
|
||||||
|
|
||||||
|
COPY ./ /app
|
||||||
|
WORKDIR /app
|
||||||
|
|
||||||
|
RUN npm install pnpm -g && pnpm install && pnpm run build
|
||||||
|
|
||||||
|
# service
|
||||||
|
FROM node:lts-alpine
|
||||||
|
|
||||||
|
COPY /service /app
|
||||||
|
COPY --from=builder /app/dist /app/public
|
||||||
|
|
||||||
|
WORKDIR /app
|
||||||
|
RUN npm install pnpm -g && pnpm install
|
||||||
|
|
||||||
|
EXPOSE 3002
|
||||||
|
|
||||||
|
CMD ["pnpm", "run", "start"]
|
||||||
42
README.md
42
README.md
@@ -23,7 +23,7 @@
|
|||||||
|
|
||||||
### Node
|
### Node
|
||||||
|
|
||||||
`node` 版本需要 >= 18,使用 [nvm](https://github.com/nvm-sh/nvm) 可管理本地多个 `node` 版本
|
`node` 需要 `^16 || ^18` 版本(或者 `node >= 14` 需要安装 [fetch polyfill](https://github.com/developit/unfetch#usage-as-a-polyfill)),使用 [nvm](https://github.com/nvm-sh/nvm) 可管理本地多个 `node` 版本
|
||||||
|
|
||||||
```shell
|
```shell
|
||||||
node -v
|
node -v
|
||||||
@@ -36,7 +36,7 @@ npm install pnpm -g
|
|||||||
```
|
```
|
||||||
|
|
||||||
### OpenAI API Key
|
### OpenAI API Key
|
||||||
获取 [OpenAI API key](https://platform.openai.com/overview) 并填写到本地环境变量
|
注册并获取 [OpenAI API key](https://platform.openai.com/overview) 并填写到本地环境变量
|
||||||
```
|
```
|
||||||
# service/.env 文件
|
# service/.env 文件
|
||||||
|
|
||||||
@@ -97,9 +97,37 @@ pnpm prod
|
|||||||
|
|
||||||
PS: 不进行打包,直接在服务器上运行 `pnpm start` 也可
|
PS: 不进行打包,直接在服务器上运行 `pnpm start` 也可
|
||||||
|
|
||||||
|
## Docker build & run
|
||||||
|
|
||||||
|
[参考信息](https://github.com/Chanzhaoyu/chatgpt-web/pull/42)
|
||||||
|
|
||||||
|
```bash
|
||||||
|
docker build -t chatgpt-web .
|
||||||
|
```
|
||||||
|
|
||||||
|
## Docker compose
|
||||||
|
|
||||||
|
[Hub 地址](https://hub.docker.com/repository/docker/chenzhaoyu94/chatgpt-web/general)
|
||||||
|
|
||||||
|
```yml
|
||||||
|
version: '3'
|
||||||
|
|
||||||
|
service:
|
||||||
|
app:
|
||||||
|
image: chenzhaoyu94/chatgpt-web
|
||||||
|
ports:
|
||||||
|
- 3002:3002
|
||||||
|
environment:
|
||||||
|
OPENAI_API_KEY: xxxxxx
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
### 网页
|
### 网页
|
||||||
|
|
||||||
根目录下运行以下命令,然后将 `dist` 文件夹复制到你的托管服务器上
|
根目录下运行以下命令,然后将 `dist` 文件夹复制到你的托管服务器上
|
||||||
|
|
||||||
|
[参考信息](https://cn.vitejs.dev/guide/static-deploy.html#building-the-app)
|
||||||
|
|
||||||
```shell
|
```shell
|
||||||
pnpm build
|
pnpm build
|
||||||
```
|
```
|
||||||
@@ -117,5 +145,15 @@ Q: 文件保存时全部爆红?
|
|||||||
|
|
||||||
A: `vscode` 请安装项目推荐插件,或手动安装 `Eslint` 插件。
|
A: `vscode` 请安装项目推荐插件,或手动安装 `Eslint` 插件。
|
||||||
|
|
||||||
|
## 参与贡献
|
||||||
|
|
||||||
|
贡献之前请先阅读 [贡献指南](./CONTRIBUTING.md)
|
||||||
|
|
||||||
|
感谢所有做过贡献的人!
|
||||||
|
|
||||||
|
<a href="https://github.com/Chanzhaoyu/chatgpt-web/graphs/contributors">
|
||||||
|
<img src="https://contrib.rocks/image?repo=Chanzhaoyu/chatgpt-web" />
|
||||||
|
</a>
|
||||||
|
|
||||||
## License
|
## License
|
||||||
MIT © [ChenZhaoYu](./license)
|
MIT © [ChenZhaoYu](./license)
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "chatgpt-web",
|
"name": "chatgpt-web",
|
||||||
"version": "2.3.1",
|
"version": "2.3.3",
|
||||||
"private": false,
|
"private": false,
|
||||||
"description": "ChatGPT Web",
|
"description": "ChatGPT Web",
|
||||||
"author": "ChenZhaoYu <chenzhaoyu1994@gmail.com>",
|
"author": "ChenZhaoYu <chenzhaoyu1994@gmail.com>",
|
||||||
@@ -16,6 +16,7 @@
|
|||||||
"preview": "vite preview",
|
"preview": "vite preview",
|
||||||
"build-only": "vite build",
|
"build-only": "vite build",
|
||||||
"type-check": "vue-tsc --noEmit",
|
"type-check": "vue-tsc --noEmit",
|
||||||
|
"lint": "eslint .",
|
||||||
"lint:fix": "eslint . --fix",
|
"lint:fix": "eslint . --fix",
|
||||||
"bootstrap": "pnpm install && pnpm run common:prepare",
|
"bootstrap": "pnpm install && pnpm run common:prepare",
|
||||||
"common:cleanup": "rimraf node_modules && rimraf pnpm-lock.yaml",
|
"common:cleanup": "rimraf node_modules && rimraf pnpm-lock.yaml",
|
||||||
@@ -37,18 +38,18 @@
|
|||||||
"@types/node": "^18.13.0",
|
"@types/node": "^18.13.0",
|
||||||
"@vitejs/plugin-vue": "^4.0.0",
|
"@vitejs/plugin-vue": "^4.0.0",
|
||||||
"autoprefixer": "^10.4.13",
|
"autoprefixer": "^10.4.13",
|
||||||
"axios": "^1.3.2",
|
"axios": "^1.3.3",
|
||||||
"crypto-js": "^4.1.1",
|
"crypto-js": "^4.1.1",
|
||||||
"eslint": "^8.34.0",
|
"eslint": "^8.34.0",
|
||||||
"husky": "^8.0.3",
|
"husky": "^8.0.3",
|
||||||
"lint-staged": "^13.1.1",
|
"lint-staged": "^13.1.2",
|
||||||
"npm-run-all": "^4.1.5",
|
"npm-run-all": "^4.1.5",
|
||||||
"postcss": "^8.4.21",
|
"postcss": "^8.4.21",
|
||||||
"rimraf": "^4.1.2",
|
"rimraf": "^4.1.2",
|
||||||
"tailwindcss": "^3.2.6",
|
"tailwindcss": "^3.2.6",
|
||||||
"typescript": "~4.9.5",
|
"typescript": "~4.9.5",
|
||||||
"vite": "^4.1.1",
|
"vite": "^4.1.1",
|
||||||
"vue-tsc": "^1.0.24"
|
"vue-tsc": "^1.1.0"
|
||||||
},
|
},
|
||||||
"lint-staged": {
|
"lint-staged": {
|
||||||
"*.{ts,tsx,vue}": [
|
"*.{ts,tsx,vue}": [
|
||||||
|
|||||||
62
pnpm-lock.yaml
generated
62
pnpm-lock.yaml
generated
@@ -9,12 +9,12 @@ specifiers:
|
|||||||
'@types/node': ^18.13.0
|
'@types/node': ^18.13.0
|
||||||
'@vitejs/plugin-vue': ^4.0.0
|
'@vitejs/plugin-vue': ^4.0.0
|
||||||
autoprefixer: ^10.4.13
|
autoprefixer: ^10.4.13
|
||||||
axios: ^1.3.2
|
axios: ^1.3.3
|
||||||
crypto-js: ^4.1.1
|
crypto-js: ^4.1.1
|
||||||
eslint: ^8.34.0
|
eslint: ^8.34.0
|
||||||
highlight.js: ^11.7.0
|
highlight.js: ^11.7.0
|
||||||
husky: ^8.0.3
|
husky: ^8.0.3
|
||||||
lint-staged: ^13.1.1
|
lint-staged: ^13.1.2
|
||||||
naive-ui: ^2.34.3
|
naive-ui: ^2.34.3
|
||||||
npm-run-all: ^4.1.5
|
npm-run-all: ^4.1.5
|
||||||
pinia: ^2.0.30
|
pinia: ^2.0.30
|
||||||
@@ -25,7 +25,7 @@ specifiers:
|
|||||||
vite: ^4.1.1
|
vite: ^4.1.1
|
||||||
vue: ^3.2.47
|
vue: ^3.2.47
|
||||||
vue-router: ^4.1.6
|
vue-router: ^4.1.6
|
||||||
vue-tsc: ^1.0.24
|
vue-tsc: ^1.1.0
|
||||||
|
|
||||||
dependencies:
|
dependencies:
|
||||||
highlight.js: 11.7.0
|
highlight.js: 11.7.0
|
||||||
@@ -54,7 +54,7 @@ devDependencies:
|
|||||||
tailwindcss: 3.2.6_postcss@8.4.21
|
tailwindcss: 3.2.6_postcss@8.4.21
|
||||||
typescript: 4.9.5
|
typescript: 4.9.5
|
||||||
vite: 4.1.1_@types+node@18.13.0
|
vite: 4.1.1_@types+node@18.13.0
|
||||||
vue-tsc: 1.0.24_typescript@4.9.5
|
vue-tsc: 1.1.0_typescript@4.9.5
|
||||||
|
|
||||||
packages:
|
packages:
|
||||||
|
|
||||||
@@ -896,43 +896,43 @@ packages:
|
|||||||
vue: 3.2.47
|
vue: 3.2.47
|
||||||
dev: true
|
dev: true
|
||||||
|
|
||||||
/@volar/language-core/1.0.24:
|
/@volar/language-core/1.2.0-alpha.11:
|
||||||
resolution: {integrity: sha512-vTN+alJiWwK0Pax6POqrmevbtFW2dXhjwWiW/MW4f48eDYPLdyURWcr8TixO7EN/nHsUBj2udT7igFKPtjyAKg==}
|
resolution: {integrity: sha512-OfbPmmFa4LUA8kJCg77V9ud4NASjJ3VKJ79QCQSfHa5SwXeZ5w7lvQe2yILFBjZ3JDB5EfFnHZUSct6ziK3x5Q==}
|
||||||
dependencies:
|
dependencies:
|
||||||
'@volar/source-map': 1.0.24
|
'@volar/source-map': 1.2.0-alpha.11
|
||||||
muggle-string: 0.1.0
|
|
||||||
dev: true
|
dev: true
|
||||||
|
|
||||||
/@volar/source-map/1.0.24:
|
/@volar/source-map/1.2.0-alpha.11:
|
||||||
resolution: {integrity: sha512-Qsv/tkplx18pgBr8lKAbM1vcDqgkGKQzbChg6NW+v0CZc3G7FLmK+WrqEPzKlN7Cwdc6XVL559Nod8WKAfKr4A==}
|
resolution: {integrity: sha512-GCRqcq2bn8Gf9N/qbdl8GgfGbmYuuSIB8arhl+gRZfCIWvT5NhIRVlG5GX0lkgpp02lA8ZYWZ0GLGOkwz7+DMQ==}
|
||||||
dependencies:
|
dependencies:
|
||||||
muggle-string: 0.1.0
|
muggle-string: 0.2.2
|
||||||
dev: true
|
dev: true
|
||||||
|
|
||||||
/@volar/typescript/1.0.24:
|
/@volar/typescript/1.2.0-alpha.11:
|
||||||
resolution: {integrity: sha512-f8hCSk+PfKR1/RQHxZ79V1NpDImHoivqoizK+mstphm25tn/YJ/JnKNjZHB+o21fuW0yKlI26NV3jkVb2Cc/7A==}
|
resolution: {integrity: sha512-tJ20326E/Xi1lvvuWX57boVJtzhStNF3HjBu4orjl9PqCXUbhqWwP+jRYzyb+nLbHqGPmEBvHKYjAO3GsJ/YXg==}
|
||||||
dependencies:
|
dependencies:
|
||||||
'@volar/language-core': 1.0.24
|
'@volar/language-core': 1.2.0-alpha.11
|
||||||
dev: true
|
dev: true
|
||||||
|
|
||||||
/@volar/vue-language-core/1.0.24:
|
/@volar/vue-language-core/1.1.0:
|
||||||
resolution: {integrity: sha512-2NTJzSgrwKu6uYwPqLiTMuAzi7fAY3yFy5PJ255bGJc82If0Xr+cW8pC80vpjG0D/aVLmlwAdO4+Ya2BI8GdDg==}
|
resolution: {integrity: sha512-1zTAyeGiyNKYE9s+i3dUpmuvY/Cz1U7LjIh9d5FX3p0NWpaBrzYvSh0gQY+nRaz67or7Y9qYSUCaHLKOmeolzg==}
|
||||||
dependencies:
|
dependencies:
|
||||||
'@volar/language-core': 1.0.24
|
'@volar/language-core': 1.2.0-alpha.11
|
||||||
'@volar/source-map': 1.0.24
|
'@volar/source-map': 1.2.0-alpha.11
|
||||||
'@vue/compiler-dom': 3.2.47
|
'@vue/compiler-dom': 3.2.47
|
||||||
'@vue/compiler-sfc': 3.2.47
|
'@vue/compiler-sfc': 3.2.47
|
||||||
'@vue/reactivity': 3.2.47
|
'@vue/reactivity': 3.2.47
|
||||||
'@vue/shared': 3.2.47
|
'@vue/shared': 3.2.47
|
||||||
minimatch: 5.1.6
|
minimatch: 6.2.0
|
||||||
|
muggle-string: 0.2.2
|
||||||
vue-template-compiler: 2.7.14
|
vue-template-compiler: 2.7.14
|
||||||
dev: true
|
dev: true
|
||||||
|
|
||||||
/@volar/vue-typescript/1.0.24:
|
/@volar/vue-typescript/1.1.0:
|
||||||
resolution: {integrity: sha512-9a25oHDvGaNC0okRS47uqJI6FxY4hUQZUsxeOUFHcqVxZEv8s17LPuP/pMMXyz7jPygrZubB/qXqHY5jEu/akA==}
|
resolution: {integrity: sha512-smtfaePuNpVzXEypJayORtl8muvBdtV1FDWjces1WLYbbtcnmfWtdACW9xY0dkVk0LoE/LZTEmLBCQrRJ6hS1w==}
|
||||||
dependencies:
|
dependencies:
|
||||||
'@volar/typescript': 1.0.24
|
'@volar/typescript': 1.2.0-alpha.11
|
||||||
'@volar/vue-language-core': 1.0.24
|
'@volar/vue-language-core': 1.1.0
|
||||||
dev: true
|
dev: true
|
||||||
|
|
||||||
/@vue/compiler-core/3.2.47:
|
/@vue/compiler-core/3.2.47:
|
||||||
@@ -3227,8 +3227,8 @@ packages:
|
|||||||
brace-expansion: 1.1.11
|
brace-expansion: 1.1.11
|
||||||
dev: true
|
dev: true
|
||||||
|
|
||||||
/minimatch/5.1.6:
|
/minimatch/6.2.0:
|
||||||
resolution: {integrity: sha512-lKwV/1brpG6mBUFHtb7NUmtABCb2WZZmm2wNiOA5hAb8VdCS4B3dtMWyvcoViccwAW/COERjXLt0zP1zXUN26g==}
|
resolution: {integrity: sha512-sauLxniAmvnhhRjFwPNnJKaPFYyddAgbYdeUpHULtCT/GhzdCx/MDNy+Y40lBxTQUrMzDE8e0S43Z5uqfO0REg==}
|
||||||
engines: {node: '>=10'}
|
engines: {node: '>=10'}
|
||||||
dependencies:
|
dependencies:
|
||||||
brace-expansion: 2.0.1
|
brace-expansion: 2.0.1
|
||||||
@@ -3255,8 +3255,8 @@ packages:
|
|||||||
resolution: {integrity: sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==}
|
resolution: {integrity: sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==}
|
||||||
dev: true
|
dev: true
|
||||||
|
|
||||||
/muggle-string/0.1.0:
|
/muggle-string/0.2.2:
|
||||||
resolution: {integrity: sha512-Tr1knR3d2mKvvWthlk7202rywKbiOm4rVFLsfAaSIhJ6dt9o47W4S+JMtWhd/PW9Wrdew2/S2fSvhz3E2gkfEg==}
|
resolution: {integrity: sha512-YVE1mIJ4VpUMqZObFndk9CJu6DBJR/GB13p3tXuNbwD4XExaI5EOuRl6BHeIDxIqXZVxSfAC+y6U1Z/IxCfKUg==}
|
||||||
dev: true
|
dev: true
|
||||||
|
|
||||||
/naive-ui/2.34.3_vue@3.2.47:
|
/naive-ui/2.34.3_vue@3.2.47:
|
||||||
@@ -4472,14 +4472,14 @@ packages:
|
|||||||
he: 1.2.0
|
he: 1.2.0
|
||||||
dev: true
|
dev: true
|
||||||
|
|
||||||
/vue-tsc/1.0.24_typescript@4.9.5:
|
/vue-tsc/1.1.0_typescript@4.9.5:
|
||||||
resolution: {integrity: sha512-mmU1s5SAqE1nByQAiQnao9oU4vX+mSdsgI8H57SfKH6UVzq/jP9+Dbi2GaV+0b4Cn361d2ln8m6xeU60ApiEXg==}
|
resolution: {integrity: sha512-+JqTcuScA6OfyaVH3ezeCh2i2wRgzUScZ6EdTZ3AW69Nb+rmRyOAxmAjL6MPam8YCdwmmdfAUhmN/BNGVp5vQg==}
|
||||||
hasBin: true
|
hasBin: true
|
||||||
peerDependencies:
|
peerDependencies:
|
||||||
typescript: '*'
|
typescript: '*'
|
||||||
dependencies:
|
dependencies:
|
||||||
'@volar/vue-language-core': 1.0.24
|
'@volar/vue-language-core': 1.1.0
|
||||||
'@volar/vue-typescript': 1.0.24
|
'@volar/vue-typescript': 1.1.0
|
||||||
typescript: 4.9.5
|
typescript: 4.9.5
|
||||||
dev: true
|
dev: true
|
||||||
|
|
||||||
|
|||||||
@@ -24,6 +24,8 @@
|
|||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"chatgpt": "^4.3.2",
|
"chatgpt": "^4.3.2",
|
||||||
|
"dotenv": "^16.0.3",
|
||||||
|
"esno": "^0.16.3",
|
||||||
"express": "^4.18.2",
|
"express": "^4.18.2",
|
||||||
"isomorphic-fetch": "^3.0.0"
|
"isomorphic-fetch": "^3.0.0"
|
||||||
},
|
},
|
||||||
@@ -31,9 +33,7 @@
|
|||||||
"@antfu/eslint-config": "^0.35.2",
|
"@antfu/eslint-config": "^0.35.2",
|
||||||
"@types/express": "^4.17.17",
|
"@types/express": "^4.17.17",
|
||||||
"@types/node": "^18.13.0",
|
"@types/node": "^18.13.0",
|
||||||
"dotenv": "^16.0.3",
|
|
||||||
"eslint": "^8.34.0",
|
"eslint": "^8.34.0",
|
||||||
"esno": "^0.16.3",
|
|
||||||
"rimraf": "^4.1.2",
|
"rimraf": "^4.1.2",
|
||||||
"tsup": "^6.6.2",
|
"tsup": "^6.6.2",
|
||||||
"typescript": "^4.9.5"
|
"typescript": "^4.9.5"
|
||||||
|
|||||||
48
service/pnpm-lock.yaml
generated
48
service/pnpm-lock.yaml
generated
@@ -16,6 +16,8 @@ specifiers:
|
|||||||
|
|
||||||
dependencies:
|
dependencies:
|
||||||
chatgpt: 4.4.0
|
chatgpt: 4.4.0
|
||||||
|
dotenv: 16.0.3
|
||||||
|
esno: 0.16.3
|
||||||
express: 4.18.2
|
express: 4.18.2
|
||||||
isomorphic-fetch: 3.0.0
|
isomorphic-fetch: 3.0.0
|
||||||
|
|
||||||
@@ -23,9 +25,7 @@ devDependencies:
|
|||||||
'@antfu/eslint-config': 0.35.2_7kw3g6rralp5ps6mg3uyzz6azm
|
'@antfu/eslint-config': 0.35.2_7kw3g6rralp5ps6mg3uyzz6azm
|
||||||
'@types/express': 4.17.17
|
'@types/express': 4.17.17
|
||||||
'@types/node': 18.13.0
|
'@types/node': 18.13.0
|
||||||
dotenv: 16.0.3
|
|
||||||
eslint: 8.34.0
|
eslint: 8.34.0
|
||||||
esno: 0.16.3
|
|
||||||
rimraf: 4.1.2
|
rimraf: 4.1.2
|
||||||
tsup: 6.6.3_typescript@4.9.5
|
tsup: 6.6.3_typescript@4.9.5
|
||||||
typescript: 4.9.5
|
typescript: 4.9.5
|
||||||
@@ -154,21 +154,21 @@ packages:
|
|||||||
dependencies:
|
dependencies:
|
||||||
'@esbuild-kit/core-utils': 3.1.0
|
'@esbuild-kit/core-utils': 3.1.0
|
||||||
get-tsconfig: 4.4.0
|
get-tsconfig: 4.4.0
|
||||||
dev: true
|
dev: false
|
||||||
|
|
||||||
/@esbuild-kit/core-utils/3.1.0:
|
/@esbuild-kit/core-utils/3.1.0:
|
||||||
resolution: {integrity: sha512-Uuk8RpCg/7fdHSceR1M6XbSZFSuMrxcePFuGgyvsBn+u339dk5OeL4jv2EojwTN2st/unJGsVm4qHWjWNmJ/tw==}
|
resolution: {integrity: sha512-Uuk8RpCg/7fdHSceR1M6XbSZFSuMrxcePFuGgyvsBn+u339dk5OeL4jv2EojwTN2st/unJGsVm4qHWjWNmJ/tw==}
|
||||||
dependencies:
|
dependencies:
|
||||||
esbuild: 0.17.8
|
esbuild: 0.17.8
|
||||||
source-map-support: 0.5.21
|
source-map-support: 0.5.21
|
||||||
dev: true
|
dev: false
|
||||||
|
|
||||||
/@esbuild-kit/esm-loader/2.5.5:
|
/@esbuild-kit/esm-loader/2.5.5:
|
||||||
resolution: {integrity: sha512-Qwfvj/qoPbClxCRNuac1Du01r9gvNOT+pMYtJDapfB1eoGN1YlJ1BixLyL9WVENRx5RXgNLdfYdx/CuswlGhMw==}
|
resolution: {integrity: sha512-Qwfvj/qoPbClxCRNuac1Du01r9gvNOT+pMYtJDapfB1eoGN1YlJ1BixLyL9WVENRx5RXgNLdfYdx/CuswlGhMw==}
|
||||||
dependencies:
|
dependencies:
|
||||||
'@esbuild-kit/core-utils': 3.1.0
|
'@esbuild-kit/core-utils': 3.1.0
|
||||||
get-tsconfig: 4.4.0
|
get-tsconfig: 4.4.0
|
||||||
dev: true
|
dev: false
|
||||||
|
|
||||||
/@esbuild/android-arm/0.17.8:
|
/@esbuild/android-arm/0.17.8:
|
||||||
resolution: {integrity: sha512-0/rb91GYKhrtbeglJXOhAv9RuYimgI8h623TplY2X+vA4EXnk3Zj1fXZreJ0J3OJJu1bwmb0W7g+2cT/d8/l/w==}
|
resolution: {integrity: sha512-0/rb91GYKhrtbeglJXOhAv9RuYimgI8h623TplY2X+vA4EXnk3Zj1fXZreJ0J3OJJu1bwmb0W7g+2cT/d8/l/w==}
|
||||||
@@ -176,7 +176,6 @@ packages:
|
|||||||
cpu: [arm]
|
cpu: [arm]
|
||||||
os: [android]
|
os: [android]
|
||||||
requiresBuild: true
|
requiresBuild: true
|
||||||
dev: true
|
|
||||||
optional: true
|
optional: true
|
||||||
|
|
||||||
/@esbuild/android-arm64/0.17.8:
|
/@esbuild/android-arm64/0.17.8:
|
||||||
@@ -185,7 +184,6 @@ packages:
|
|||||||
cpu: [arm64]
|
cpu: [arm64]
|
||||||
os: [android]
|
os: [android]
|
||||||
requiresBuild: true
|
requiresBuild: true
|
||||||
dev: true
|
|
||||||
optional: true
|
optional: true
|
||||||
|
|
||||||
/@esbuild/android-x64/0.17.8:
|
/@esbuild/android-x64/0.17.8:
|
||||||
@@ -194,7 +192,6 @@ packages:
|
|||||||
cpu: [x64]
|
cpu: [x64]
|
||||||
os: [android]
|
os: [android]
|
||||||
requiresBuild: true
|
requiresBuild: true
|
||||||
dev: true
|
|
||||||
optional: true
|
optional: true
|
||||||
|
|
||||||
/@esbuild/darwin-arm64/0.17.8:
|
/@esbuild/darwin-arm64/0.17.8:
|
||||||
@@ -203,7 +200,6 @@ packages:
|
|||||||
cpu: [arm64]
|
cpu: [arm64]
|
||||||
os: [darwin]
|
os: [darwin]
|
||||||
requiresBuild: true
|
requiresBuild: true
|
||||||
dev: true
|
|
||||||
optional: true
|
optional: true
|
||||||
|
|
||||||
/@esbuild/darwin-x64/0.17.8:
|
/@esbuild/darwin-x64/0.17.8:
|
||||||
@@ -212,7 +208,6 @@ packages:
|
|||||||
cpu: [x64]
|
cpu: [x64]
|
||||||
os: [darwin]
|
os: [darwin]
|
||||||
requiresBuild: true
|
requiresBuild: true
|
||||||
dev: true
|
|
||||||
optional: true
|
optional: true
|
||||||
|
|
||||||
/@esbuild/freebsd-arm64/0.17.8:
|
/@esbuild/freebsd-arm64/0.17.8:
|
||||||
@@ -221,7 +216,6 @@ packages:
|
|||||||
cpu: [arm64]
|
cpu: [arm64]
|
||||||
os: [freebsd]
|
os: [freebsd]
|
||||||
requiresBuild: true
|
requiresBuild: true
|
||||||
dev: true
|
|
||||||
optional: true
|
optional: true
|
||||||
|
|
||||||
/@esbuild/freebsd-x64/0.17.8:
|
/@esbuild/freebsd-x64/0.17.8:
|
||||||
@@ -230,7 +224,6 @@ packages:
|
|||||||
cpu: [x64]
|
cpu: [x64]
|
||||||
os: [freebsd]
|
os: [freebsd]
|
||||||
requiresBuild: true
|
requiresBuild: true
|
||||||
dev: true
|
|
||||||
optional: true
|
optional: true
|
||||||
|
|
||||||
/@esbuild/linux-arm/0.17.8:
|
/@esbuild/linux-arm/0.17.8:
|
||||||
@@ -239,7 +232,6 @@ packages:
|
|||||||
cpu: [arm]
|
cpu: [arm]
|
||||||
os: [linux]
|
os: [linux]
|
||||||
requiresBuild: true
|
requiresBuild: true
|
||||||
dev: true
|
|
||||||
optional: true
|
optional: true
|
||||||
|
|
||||||
/@esbuild/linux-arm64/0.17.8:
|
/@esbuild/linux-arm64/0.17.8:
|
||||||
@@ -248,7 +240,6 @@ packages:
|
|||||||
cpu: [arm64]
|
cpu: [arm64]
|
||||||
os: [linux]
|
os: [linux]
|
||||||
requiresBuild: true
|
requiresBuild: true
|
||||||
dev: true
|
|
||||||
optional: true
|
optional: true
|
||||||
|
|
||||||
/@esbuild/linux-ia32/0.17.8:
|
/@esbuild/linux-ia32/0.17.8:
|
||||||
@@ -257,7 +248,6 @@ packages:
|
|||||||
cpu: [ia32]
|
cpu: [ia32]
|
||||||
os: [linux]
|
os: [linux]
|
||||||
requiresBuild: true
|
requiresBuild: true
|
||||||
dev: true
|
|
||||||
optional: true
|
optional: true
|
||||||
|
|
||||||
/@esbuild/linux-loong64/0.17.8:
|
/@esbuild/linux-loong64/0.17.8:
|
||||||
@@ -266,7 +256,6 @@ packages:
|
|||||||
cpu: [loong64]
|
cpu: [loong64]
|
||||||
os: [linux]
|
os: [linux]
|
||||||
requiresBuild: true
|
requiresBuild: true
|
||||||
dev: true
|
|
||||||
optional: true
|
optional: true
|
||||||
|
|
||||||
/@esbuild/linux-mips64el/0.17.8:
|
/@esbuild/linux-mips64el/0.17.8:
|
||||||
@@ -275,7 +264,6 @@ packages:
|
|||||||
cpu: [mips64el]
|
cpu: [mips64el]
|
||||||
os: [linux]
|
os: [linux]
|
||||||
requiresBuild: true
|
requiresBuild: true
|
||||||
dev: true
|
|
||||||
optional: true
|
optional: true
|
||||||
|
|
||||||
/@esbuild/linux-ppc64/0.17.8:
|
/@esbuild/linux-ppc64/0.17.8:
|
||||||
@@ -284,7 +272,6 @@ packages:
|
|||||||
cpu: [ppc64]
|
cpu: [ppc64]
|
||||||
os: [linux]
|
os: [linux]
|
||||||
requiresBuild: true
|
requiresBuild: true
|
||||||
dev: true
|
|
||||||
optional: true
|
optional: true
|
||||||
|
|
||||||
/@esbuild/linux-riscv64/0.17.8:
|
/@esbuild/linux-riscv64/0.17.8:
|
||||||
@@ -293,7 +280,6 @@ packages:
|
|||||||
cpu: [riscv64]
|
cpu: [riscv64]
|
||||||
os: [linux]
|
os: [linux]
|
||||||
requiresBuild: true
|
requiresBuild: true
|
||||||
dev: true
|
|
||||||
optional: true
|
optional: true
|
||||||
|
|
||||||
/@esbuild/linux-s390x/0.17.8:
|
/@esbuild/linux-s390x/0.17.8:
|
||||||
@@ -302,7 +288,6 @@ packages:
|
|||||||
cpu: [s390x]
|
cpu: [s390x]
|
||||||
os: [linux]
|
os: [linux]
|
||||||
requiresBuild: true
|
requiresBuild: true
|
||||||
dev: true
|
|
||||||
optional: true
|
optional: true
|
||||||
|
|
||||||
/@esbuild/linux-x64/0.17.8:
|
/@esbuild/linux-x64/0.17.8:
|
||||||
@@ -311,7 +296,6 @@ packages:
|
|||||||
cpu: [x64]
|
cpu: [x64]
|
||||||
os: [linux]
|
os: [linux]
|
||||||
requiresBuild: true
|
requiresBuild: true
|
||||||
dev: true
|
|
||||||
optional: true
|
optional: true
|
||||||
|
|
||||||
/@esbuild/netbsd-x64/0.17.8:
|
/@esbuild/netbsd-x64/0.17.8:
|
||||||
@@ -320,7 +304,6 @@ packages:
|
|||||||
cpu: [x64]
|
cpu: [x64]
|
||||||
os: [netbsd]
|
os: [netbsd]
|
||||||
requiresBuild: true
|
requiresBuild: true
|
||||||
dev: true
|
|
||||||
optional: true
|
optional: true
|
||||||
|
|
||||||
/@esbuild/openbsd-x64/0.17.8:
|
/@esbuild/openbsd-x64/0.17.8:
|
||||||
@@ -329,7 +312,6 @@ packages:
|
|||||||
cpu: [x64]
|
cpu: [x64]
|
||||||
os: [openbsd]
|
os: [openbsd]
|
||||||
requiresBuild: true
|
requiresBuild: true
|
||||||
dev: true
|
|
||||||
optional: true
|
optional: true
|
||||||
|
|
||||||
/@esbuild/sunos-x64/0.17.8:
|
/@esbuild/sunos-x64/0.17.8:
|
||||||
@@ -338,7 +320,6 @@ packages:
|
|||||||
cpu: [x64]
|
cpu: [x64]
|
||||||
os: [sunos]
|
os: [sunos]
|
||||||
requiresBuild: true
|
requiresBuild: true
|
||||||
dev: true
|
|
||||||
optional: true
|
optional: true
|
||||||
|
|
||||||
/@esbuild/win32-arm64/0.17.8:
|
/@esbuild/win32-arm64/0.17.8:
|
||||||
@@ -347,7 +328,6 @@ packages:
|
|||||||
cpu: [arm64]
|
cpu: [arm64]
|
||||||
os: [win32]
|
os: [win32]
|
||||||
requiresBuild: true
|
requiresBuild: true
|
||||||
dev: true
|
|
||||||
optional: true
|
optional: true
|
||||||
|
|
||||||
/@esbuild/win32-ia32/0.17.8:
|
/@esbuild/win32-ia32/0.17.8:
|
||||||
@@ -356,7 +336,6 @@ packages:
|
|||||||
cpu: [ia32]
|
cpu: [ia32]
|
||||||
os: [win32]
|
os: [win32]
|
||||||
requiresBuild: true
|
requiresBuild: true
|
||||||
dev: true
|
|
||||||
optional: true
|
optional: true
|
||||||
|
|
||||||
/@esbuild/win32-x64/0.17.8:
|
/@esbuild/win32-x64/0.17.8:
|
||||||
@@ -365,7 +344,6 @@ packages:
|
|||||||
cpu: [x64]
|
cpu: [x64]
|
||||||
os: [win32]
|
os: [win32]
|
||||||
requiresBuild: true
|
requiresBuild: true
|
||||||
dev: true
|
|
||||||
optional: true
|
optional: true
|
||||||
|
|
||||||
/@eslint-community/eslint-utils/4.1.2_eslint@8.34.0:
|
/@eslint-community/eslint-utils/4.1.2_eslint@8.34.0:
|
||||||
@@ -805,7 +783,7 @@ packages:
|
|||||||
|
|
||||||
/buffer-from/1.1.2:
|
/buffer-from/1.1.2:
|
||||||
resolution: {integrity: sha512-E+XQCRwSbaaiChtv6k6Dwgc+bx+Bs6vuKJHHl5kox/BaKbhiXzqQOwK4cO22yElGp2OCmjwVhT3HmxgyPGnJfQ==}
|
resolution: {integrity: sha512-E+XQCRwSbaaiChtv6k6Dwgc+bx+Bs6vuKJHHl5kox/BaKbhiXzqQOwK4cO22yElGp2OCmjwVhT3HmxgyPGnJfQ==}
|
||||||
dev: true
|
dev: false
|
||||||
|
|
||||||
/builtin-modules/3.3.0:
|
/builtin-modules/3.3.0:
|
||||||
resolution: {integrity: sha512-zhaCDicdLuWN5UbN5IMnFqNMhNfo919sH85y2/ea+5Yg9TsTkeZxpL+JLbp6cgYFS4sRLp3YV4S6yDuqVWHYOw==}
|
resolution: {integrity: sha512-zhaCDicdLuWN5UbN5IMnFqNMhNfo919sH85y2/ea+5Yg9TsTkeZxpL+JLbp6cgYFS4sRLp3YV4S6yDuqVWHYOw==}
|
||||||
@@ -1090,7 +1068,7 @@ packages:
|
|||||||
/dotenv/16.0.3:
|
/dotenv/16.0.3:
|
||||||
resolution: {integrity: sha512-7GO6HghkA5fYG9TYnNxi14/7K9f5occMlp3zXAuSxn7CKCxt9xbNWG7yF8hTCSUchlfWSe3uLmlPfigevRItzQ==}
|
resolution: {integrity: sha512-7GO6HghkA5fYG9TYnNxi14/7K9f5occMlp3zXAuSxn7CKCxt9xbNWG7yF8hTCSUchlfWSe3uLmlPfigevRItzQ==}
|
||||||
engines: {node: '>=12'}
|
engines: {node: '>=12'}
|
||||||
dev: true
|
dev: false
|
||||||
|
|
||||||
/ee-first/1.1.1:
|
/ee-first/1.1.1:
|
||||||
resolution: {integrity: sha512-WMwm9LhRUo+WUaRN+vRuETqG89IgZphVSNkdFgeb6sS/E4OrDIN7t48CAewSHXc6C8lefD8KKfr5vY61brQlow==}
|
resolution: {integrity: sha512-WMwm9LhRUo+WUaRN+vRuETqG89IgZphVSNkdFgeb6sS/E4OrDIN7t48CAewSHXc6C8lefD8KKfr5vY61brQlow==}
|
||||||
@@ -1203,7 +1181,6 @@ packages:
|
|||||||
'@esbuild/win32-arm64': 0.17.8
|
'@esbuild/win32-arm64': 0.17.8
|
||||||
'@esbuild/win32-ia32': 0.17.8
|
'@esbuild/win32-ia32': 0.17.8
|
||||||
'@esbuild/win32-x64': 0.17.8
|
'@esbuild/win32-x64': 0.17.8
|
||||||
dev: true
|
|
||||||
|
|
||||||
/escape-html/1.0.3:
|
/escape-html/1.0.3:
|
||||||
resolution: {integrity: sha512-NiSupZ4OeuGwr68lGIeym/ksIZMJodUGOSCZ/FSnTxcrekbvqrgdUxlJOMpijaKZVjAJrWrGs/6Jy8OMuyj9ow==}
|
resolution: {integrity: sha512-NiSupZ4OeuGwr68lGIeym/ksIZMJodUGOSCZ/FSnTxcrekbvqrgdUxlJOMpijaKZVjAJrWrGs/6Jy8OMuyj9ow==}
|
||||||
@@ -1584,7 +1561,7 @@ packages:
|
|||||||
hasBin: true
|
hasBin: true
|
||||||
dependencies:
|
dependencies:
|
||||||
tsx: 3.12.3
|
tsx: 3.12.3
|
||||||
dev: true
|
dev: false
|
||||||
|
|
||||||
/espree/9.4.1:
|
/espree/9.4.1:
|
||||||
resolution: {integrity: sha512-XwctdmTO6SIvCzd9810yyNzIrOrqNYV9Koizx4C/mRhf9uq0o4yHoCEU/670pOxOL/MSraektvSAji79kX90Vg==}
|
resolution: {integrity: sha512-XwctdmTO6SIvCzd9810yyNzIrOrqNYV9Koizx4C/mRhf9uq0o4yHoCEU/670pOxOL/MSraektvSAji79kX90Vg==}
|
||||||
@@ -1799,7 +1776,6 @@ packages:
|
|||||||
engines: {node: ^8.16.0 || ^10.6.0 || >=11.0.0}
|
engines: {node: ^8.16.0 || ^10.6.0 || >=11.0.0}
|
||||||
os: [darwin]
|
os: [darwin]
|
||||||
requiresBuild: true
|
requiresBuild: true
|
||||||
dev: true
|
|
||||||
optional: true
|
optional: true
|
||||||
|
|
||||||
/function-bind/1.1.1:
|
/function-bind/1.1.1:
|
||||||
@@ -1841,7 +1817,7 @@ packages:
|
|||||||
|
|
||||||
/get-tsconfig/4.4.0:
|
/get-tsconfig/4.4.0:
|
||||||
resolution: {integrity: sha512-0Gdjo/9+FzsYhXCEFueo2aY1z1tpXrxWZzP7k8ul9qt1U5o8rYJwTJYmaeHdrVosYIVYkOy2iwCJ9FdpocJhPQ==}
|
resolution: {integrity: sha512-0Gdjo/9+FzsYhXCEFueo2aY1z1tpXrxWZzP7k8ul9qt1U5o8rYJwTJYmaeHdrVosYIVYkOy2iwCJ9FdpocJhPQ==}
|
||||||
dev: true
|
dev: false
|
||||||
|
|
||||||
/glob-parent/5.1.2:
|
/glob-parent/5.1.2:
|
||||||
resolution: {integrity: sha512-AOIgSQCepiJYwP3ARnGx+5VnTu2HBYdzbGP45eLw1vr3zB3vZLeyed1sC9hnbcOc9/SrMyM5RPQrkGz4aS9Zow==}
|
resolution: {integrity: sha512-AOIgSQCepiJYwP3ARnGx+5VnTu2HBYdzbGP45eLw1vr3zB3vZLeyed1sC9hnbcOc9/SrMyM5RPQrkGz4aS9Zow==}
|
||||||
@@ -2977,12 +2953,12 @@ packages:
|
|||||||
dependencies:
|
dependencies:
|
||||||
buffer-from: 1.1.2
|
buffer-from: 1.1.2
|
||||||
source-map: 0.6.1
|
source-map: 0.6.1
|
||||||
dev: true
|
dev: false
|
||||||
|
|
||||||
/source-map/0.6.1:
|
/source-map/0.6.1:
|
||||||
resolution: {integrity: sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==}
|
resolution: {integrity: sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==}
|
||||||
engines: {node: '>=0.10.0'}
|
engines: {node: '>=0.10.0'}
|
||||||
dev: true
|
dev: false
|
||||||
|
|
||||||
/source-map/0.8.0-beta.0:
|
/source-map/0.8.0-beta.0:
|
||||||
resolution: {integrity: sha512-2ymg6oRBpebeZi9UUNsgQ89bhx01TcTkmNTGnNO88imTmbSgy4nfujrgVEFKWpMTEGA11EDkTt7mqObTPdigIA==}
|
resolution: {integrity: sha512-2ymg6oRBpebeZi9UUNsgQ89bhx01TcTkmNTGnNO88imTmbSgy4nfujrgVEFKWpMTEGA11EDkTt7mqObTPdigIA==}
|
||||||
@@ -3211,7 +3187,7 @@ packages:
|
|||||||
'@esbuild-kit/esm-loader': 2.5.5
|
'@esbuild-kit/esm-loader': 2.5.5
|
||||||
optionalDependencies:
|
optionalDependencies:
|
||||||
fsevents: 2.3.2
|
fsevents: 2.3.2
|
||||||
dev: true
|
dev: false
|
||||||
|
|
||||||
/type-check/0.4.0:
|
/type-check/0.4.0:
|
||||||
resolution: {integrity: sha512-XleUoc9uwGXqjWwXaUTZAmzMcFZ5858QA2vvx1Ur5xIcixXIP+8LnFDgRplU30us6teqdlskFfu+ae4K79Ooew==}
|
resolution: {integrity: sha512-XleUoc9uwGXqjWwXaUTZAmzMcFZ5858QA2vvx1Ur5xIcixXIP+8LnFDgRplU30us6teqdlskFfu+ae4K79Ooew==}
|
||||||
|
|||||||
@@ -3,6 +3,11 @@ import 'isomorphic-fetch'
|
|||||||
import type { ChatGPTAPI, SendMessageOptions } from 'chatgpt'
|
import type { ChatGPTAPI, SendMessageOptions } from 'chatgpt'
|
||||||
import { sendResponse } from './utils'
|
import { sendResponse } from './utils'
|
||||||
|
|
||||||
|
export interface ChatContext {
|
||||||
|
conversationId?: string
|
||||||
|
parentMessageId?: string
|
||||||
|
}
|
||||||
|
|
||||||
dotenv.config()
|
dotenv.config()
|
||||||
|
|
||||||
const apiKey = process.env.OPENAI_API_KEY
|
const apiKey = process.env.OPENAI_API_KEY
|
||||||
|
|||||||
@@ -3,7 +3,9 @@ import type { ChatContext } from './chatgpt'
|
|||||||
import { chatReply } from './chatgpt'
|
import { chatReply } from './chatgpt'
|
||||||
|
|
||||||
const app = express()
|
const app = express()
|
||||||
|
const router = express.Router()
|
||||||
|
|
||||||
|
app.use(express.static('public'))
|
||||||
app.use(express.json())
|
app.use(express.json())
|
||||||
|
|
||||||
app.all('*', (_, res, next) => {
|
app.all('*', (_, res, next) => {
|
||||||
@@ -13,7 +15,7 @@ app.all('*', (_, res, next) => {
|
|||||||
next()
|
next()
|
||||||
})
|
})
|
||||||
|
|
||||||
app.post('/chat', async (req, res) => {
|
router.post('/chat', async (req, res) => {
|
||||||
try {
|
try {
|
||||||
const { prompt, options = {} } = req.body as { prompt: string; options?: ChatContext }
|
const { prompt, options = {} } = req.body as { prompt: string; options?: ChatContext }
|
||||||
const response = await chatReply(prompt, options)
|
const response = await chatReply(prompt, options)
|
||||||
@@ -24,4 +26,7 @@ app.post('/chat', async (req, res) => {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
app.use('', router)
|
||||||
|
app.use('/api', router)
|
||||||
|
|
||||||
app.listen(3002, () => globalThis.console.log('Server is running on port 3002'))
|
app.listen(3002, () => globalThis.console.log('Server is running on port 3002'))
|
||||||
|
|||||||
@@ -1,8 +1,6 @@
|
|||||||
import type { GenericAbortSignal } from 'axios'
|
import type { GenericAbortSignal } from 'axios'
|
||||||
import { post } from '@/utils/request'
|
import { post } from '@/utils/request'
|
||||||
|
|
||||||
export const controller = new AbortController()
|
|
||||||
|
|
||||||
export function fetchChatAPI<T = any>(
|
export function fetchChatAPI<T = any>(
|
||||||
prompt: string,
|
prompt: string,
|
||||||
options?: { conversationId?: string; parentMessageId?: string },
|
options?: { conversationId?: string; parentMessageId?: string },
|
||||||
|
|||||||
@@ -9,8 +9,5 @@ export const useAppStore = defineStore('app-store', {
|
|||||||
this.siderCollapsed = collapsed
|
this.siderCollapsed = collapsed
|
||||||
setLocalSetting(this.$state)
|
setLocalSetting(this.$state)
|
||||||
},
|
},
|
||||||
toggleSiderCollapse() {
|
|
||||||
this.setSiderCollapsed(!this.siderCollapsed)
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ export function isNull<T extends null>(value: T | unknown): value is null {
|
|||||||
return Object.prototype.toString.call(value) === '[object Null]'
|
return Object.prototype.toString.call(value) === '[object Null]'
|
||||||
}
|
}
|
||||||
|
|
||||||
export function isUndefine<T extends undefined>(value: T | unknown): value is undefined {
|
export function isUndefined<T extends undefined>(value: T | unknown): value is undefined {
|
||||||
return Object.prototype.toString.call(value) === '[object Undefined]'
|
return Object.prototype.toString.call(value) === '[object Undefined]'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -11,10 +11,6 @@ export interface HttpOption {
|
|||||||
afterRequest?: () => void
|
afterRequest?: () => void
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface ExtraOption {
|
|
||||||
notification?: boolean
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface Response<T = any> {
|
export interface Response<T = any> {
|
||||||
data: T
|
data: T
|
||||||
message: string | null
|
message: string | null
|
||||||
|
|||||||
Reference in New Issue
Block a user