Compare commits

..

No commits in common. "cb3e98362020727d257139714a93be3232b5f0f2" and "22ee5a71b23f87d7e445072ad64f645f23d318a9" have entirely different histories.

18 changed files with 343 additions and 875 deletions

4
.gitignore vendored
View File

@ -3,6 +3,4 @@ logs
pnpm-lock.yaml
.env
/public/file
.DS_Store
data
sql
.DS_Store

View File

@ -1,4 +0,0 @@
{
"MD033": false,
"MD013": false
}

View File

@ -1,145 +0,0 @@
# 部署指南
## Node.js 部署
### 1. 安装 Node.js 环境
推荐使用 `nvm` (Node Version Manager) 来安装 Node.js。
- 首先,安装 `nvm`,你可以从 [nvm GitHub 仓库](https://github.com/nvm-sh/nvm) 找到安装指南。
- 按照仓库中的安装说明进行操作,安装完成后,可能需要添加环境变量或重启终端。
- 安装 Node.js 版本 18 或更高版本:
```shell
nvm install 18
nvm use 18
```
- 验证 Node.js 是否安装成功:
```shell
node -v
```
### 2. 安装 PM2 / PNPMYARN
- 使用 npm 安装 PM2
```shell
npm install pm2 -g
```
- 使用 npm 安装 pnpm
```shell
npm install -g pnpm
```
- 确认 `PM2``pnpm` 都已正确安装并且可以运行:
```shell
pm2 -v
pnpm -v
```
### 3. 其他配置
- 需配置 Redis 数据库以及新建一个 MySQL 数据库。
- 配置环境变量:
- 复制 `.env.example` 文件为 `.env`
- 根据需要修改 `.env` 文件中的配置项。
完成配置并启动后,项目会自动在指定的 MySQL 数据库中创建所需的表结构和初始数据,无需手动导入 SQL 文件。确保 `.env` 文件中的数据库连接信息正确即可。
### 4. 安装启动
- 安装依赖:(若安装缓慢可尝试使用国内源)
```shell
pnpm install
```
- 启动进程:(默认使用 PM2 后台运行)
```shell
pnpm start
```
- 查看运行日志:
```shell
pnpm logs
```
- 项目默认在 `9520` 端口运行,也可在环境变量中自行修改。成功运行后可通过 `IP:端口` 访问,或者配置 Nginx 反向代理,通过域名访问。
## 脚本部署
### 功能支持
- **Node.js 全新部署**
自动安装环境、生成配置、安装依赖并启动服务。
- **Node.js 升级**
拉取最新代码,更新依赖并重启服务。
- **Docker-compose 部署**
创建 MySQL、Redis 容器及 99AI 服务,支持自定义端口。
- **Docker-compose 升级**
停止旧版本容器,重新构建镜像并启动。
请在项目的根目录下执行以下命令:
```bash
./deploy.sh
```
## Docker 部署
### 1. 安装 Docker 及 Docker-compose
- 使用 [Docker 官网](https://www.docker.com/) 提供的一键安装链接安装 Docker 及 Docker-compose。
```bash
curl -fsSL https://get.docker.com | bash -s docker
```
- 也可以使用其他方式自行安装 Docker 及 Docker-compose。
### 2. 服务管理
- **后台启动服务**
```shell
docker-compose up -d
```
- **查看日志**
```shell
docker-compose logs
```
- **停止服务**
```shell
docker-compose down
```
- **重新构建并启动服务**
```shell
docker-compose up -d --build
```
## 项目管理
普通管理员,可以预览后台非敏感信息,默认不激活。请使用超级管理员账号登入后台,并及时修改密码。
- **管理端地址**`项目链接/admin`
- **普通管理员账号**`admin`(默认不激活)
- **超级管理员账号**`super`
- **密码**`123456`

254
LICENSE
View File

@ -1,127 +1,229 @@
# Apache License
Apache License
Version 2.0, January 2004
[http://www.apache.org/licenses/](http://www.apache.org/licenses/)
http://www.apache.org/licenses/ TERMS
AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
---
1. Definitions.
## TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
### 1. Definitions
- **"License"**
Shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document.
"License" shall mean the terms and conditions for use, reproduction, and
distribution as defined by Sections 1 through 9 of this document.
- **"Licensor"**
Shall mean the copyright owner or entity authorized by the copyright owner that is granting the License.
- **"Legal Entity"**
Shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity.
For the purposes of this definition, "control" means:
(i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or
(ii) ownership of fifty percent (50%) or more of the outstanding shares, or
(iii) beneficial ownership of such entity.
"Licensor" shall mean the copyright owner or entity authorized by the copyright
owner that is granting the License.
- **"You" (or "Your")**
Shall mean an individual or Legal Entity exercising permissions granted by this License.
- **"Source" form**
Shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files.
"Legal Entity" shall mean the
union of the acting entity and all other entities that control, are controlled
by, or are under common control with that entity. For the purposes of this
definition, "control" means (i) the power, direct or indirect, to cause the
direction or management of such entity, whether by contract or otherwise, or (ii)
ownership of fifty percent (50%) or more of the outstanding shares, or (iii)
beneficial ownership of such entity.
- **"Object" form**
Shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types.
- **"Work"**
Shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work (an example is provided in the Appendix below).
"You" (or "Your") shall mean
an individual or Legal Entity exercising permissions granted by this License.
- **"Derivative Works"**
Shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship.
For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof.
- **"Contribution"**
Shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner.
For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as "Not a Contribution."
- **"Contributor"**
Shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work.
"Source" form shall mean the preferred form for making modifications,
including but not limited to software source code, documentation source, and
configuration files.
---
### 2. Grant of Copyright License
"Object" form shall mean any form resulting
from mechanical transformation or translation of a Source form, including but not
limited to compiled object code, generated documentation, and conversions to
other media types.
Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form.
---
"Work" shall mean the work of authorship,
whether in Source or Object form, made available under the License, as indicated
by a copyright notice that is included in or attached to the work (an example is
provided in the Appendix below).
### 3. Grant of Patent License
Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work to which such Contribution(s) was submitted.
If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed.
"Derivative Works" shall mean any
work, whether in Source or Object form, that is based on (or derived from) the
Work and for which the editorial revisions, annotations, elaborations, or other
modifications represent, as a whole, an original work of authorship. For the
purposes of this License, Derivative Works shall not include works that remain
separable from, or merely link (or bind by name) to the interfaces of, the Work
and Derivative Works thereof.
---
### 4. Redistribution
"Contribution" shall mean any work
of authorship, including the original version of the Work and any modifications
or additions to that Work or Derivative Works thereof, that is intentionally
submitted to Licensor for inclusion in the Work by the copyright owner or by an
individual or Legal Entity authorized to submit on behalf of the copyright owner.
For the purposes of this definition, "submitted" means any form of electronic,
verbal, or written communication sent to the Licensor or its representatives,
including but not limited to communication on electronic mailing lists, source
code control systems, and issue tracking systems that are managed by, or on
behalf of, the Licensor for the purpose of discussing and improving the Work, but
excluding communication that is conspicuously marked or otherwise designated in
writing by the copyright owner as "Not a Contribution."
You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions:
- (a) You must give any other recipients of the Work or Derivative Works a copy of this License; and
- (b) You must cause any modified files to carry prominent notices stating that You changed the files; and
- (c) You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and
- (d) If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file.
"Contributor" shall mean Licensor and any individual or Legal Entity on behalf of
whom a Contribution has been received by Licensor and subsequently incorporated
within the Work.
You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License.
2. Grant of Copyright License. Subject to the terms and
conditions of this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license
to reproduce, prepare Derivative Works of, publicly display, publicly perform,
sublicense, and distribute the Work and such Derivative Works in Source or Object
form.
---
3. Grant of Patent License. Subject to the terms and conditions of this
License, each Contributor hereby grants to You a perpetual, worldwide,
non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this
section) patent license to make, have made, use, offer to sell, sell, import, and
otherwise transfer the Work, where such license applies only to those patent
claims licensable by such Contributor that are necessarily infringed by their
Contribution(s) alone or by combination of their Contribution(s) with the Work to
which such Contribution(s) was submitted. If You institute patent litigation
against any entity (including a cross-claim or counterclaim in a lawsuit)
alleging that the Work or a Contribution incorporated within the Work constitutes
direct or contributory patent infringement, then any patent licenses granted to
You under this License for that Work shall terminate as of the date such
litigation is filed.
### 5. Submission of Contributions
4. Redistribution. You may reproduce and distribute
copies of the Work or Derivative Works thereof in any medium, with or without
modifications, and in Source or Object form, provided that You meet the following
conditions:
Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions.
(a) You must give any other recipients of the Work or
Derivative Works a copy of this License; and
---
(b) You must cause any
modified files to carry prominent notices stating that You changed the files;
and
### 6. Trademarks
(c) You must retain, in the Source form of any Derivative Works that
You distribute, all copyright, patent, trademark, and attribution notices from
the Source form of the Work, excluding those notices that do not pertain to any
part of the Derivative Works; and
This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file.
(d) If the Work includes a "NOTICE" text
file as part of its distribution, then any Derivative Works that You distribute
must include a readable copy of the attribution notices contained within such
NOTICE file, excluding those notices that do not pertain to any part of the
Derivative Works, in at least one of the following places: within a NOTICE text
file distributed as part of the Derivative Works; within the Source form or
documentation, if provided along with the Derivative Works; or, within a display
generated by the Derivative Works, if and wherever such third-party notices
normally appear. The contents of the NOTICE file are for informational purposes
only and do not modify the License. You may add Your own attribution notices
within Derivative Works that You distribute, alongside or as an addendum to the
NOTICE text from the Work, provided that such additional attribution notices
cannot be construed as modifying the License.
---
You may add Your own
copyright statement to Your modifications and may provide additional or different
license terms and conditions for use, reproduction, or distribution of Your
modifications, or for any such Derivative Works as a whole, provided Your use,
reproduction, and distribution of the Work otherwise complies with the conditions
stated in this License.
### 7. Disclaimer of Warranty
5. Submission of Contributions. Unless You explicitly
state otherwise, any Contribution intentionally submitted for inclusion in the
Work by You to the Licensor shall be under the terms and conditions of this
License, without any additional terms or conditions. Notwithstanding the above,
nothing herein shall supersede or modify the terms of any separate license
agreement you may have executed with Licensor regarding such Contributions.
Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND.
6. Trademarks. This License does not grant permission to use the trade names,
trademarks, service marks, or product names of the Licensor, except as required
for reasonable and customary use in describing the origin of the Work and
reproducing the content of the NOTICE file.
---
7. Disclaimer of Warranty. Unless
required by applicable law or agreed to in writing, Licensor provides the Work
(and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT
WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including,
without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT,
MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible
for determining the appropriateness of using or redistributing the Work and
assume any risks associated with Your exercise of permissions under this
License.
### 8. Limitation of Liability
8. Limitation of Liability. In no event and under no legal theory,
whether in tort (including negligence), contract, or otherwise, unless required
by applicable law (such as deliberate and grossly negligent acts) or agreed to in
writing, shall any Contributor be liable to You for damages, including any
direct, indirect, special, incidental, or consequential damages of any character
arising as a result of this License or out of the use or inability to use the
Work (including but not limited to damages for loss of goodwill, work stoppage,
computer failure or malfunction, or any and all other commercial damages or
losses), even if such Contributor has been advised of the possibility of such
damages.
In no event and under no legal theory shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages.
9. Accepting Warranty or Additional Liability. While redistributing
the Work or Derivative Works thereof, You may choose to offer, and charge a fee
for, acceptance of support, warranty, indemnity, or other liability obligations
and/or rights consistent with this License. However, in accepting such
obligations, You may act only on Your own behalf and on Your sole responsibility,
not on behalf of any other Contributor, and only if You agree to indemnify,
defend, and hold each Contributor harmless for any liability incurred by, or
claims asserted against, such Contributor by reason of your accepting any such
warranty or additional liability. END OF TERMS AND CONDITIONS
---
APPENDIX: How to
apply the Apache License to your work.
### 9. Accepting Warranty or Additional Liability
To apply the Apache License to your work,
attach the following boilerplate notice, with the fields enclosed by brackets
"[]" replaced with your own identifying information. (Don't include the
brackets!) The text should be enclosed in the appropriate comment syntax for the
file format. We also recommend that a file or class name and description of
purpose be included on the same "printed page" as the copyright notice for easier
identification within third-party archives.
While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License.
Copyright [yyyy] vastxie
---
Licensed
under the Apache License, Version 2.0 (the "License");
## APPENDIX: How to Apply the Apache License to Your Work
you may not use this file
except in compliance with the License.
To apply the Apache License to your work, attach the following boilerplate notice:
You may obtain a copy of the License
at
```plaintext
Copyright 2024 vastxie
http://www.apache.org/licenses/LICENSE-2.0
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Unless required by applicable law
or agreed to in writing, software
You may obtain a copy of the License at:
distributed under the License is distributed
on an "AS IS" BASIS,
http://www.apache.org/licenses/LICENSE-2.0
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
express or implied.
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing
permissions and
See the License for the specific language governing permissions and
limitations under the License.
```
limitations under the License.

194
README.md
View File

@ -2,9 +2,7 @@
可商业化的 AI Web 应用,旨在提供一个易部署、低门槛的集成化人工智能服务站点,支持多种部署方式。
为了方便用户部署,项目已经 **打包完成**,可直接运行部署。源码支持商用、二次开发及分发,但请保留[出处](https://github.com/vastxie/99AI),共同维护社区生态。
**二次开发源码** 存放于 `src` 目录下,开发者可以根据需要自由修改和扩展。
源码可商用,支持二开及分发,但不要仅改名后割韭菜,尽量保留[出处](https://github.com/vastxie/99AI),有兴趣的小伙伴可共同维护。
## 项目介绍
@ -14,7 +12,7 @@
<img width="1444" alt="image" src="https://github.com/vastxie/99AI/assets/24899308/dd373bec-674e-4a6c-8304-f6abd1a65e1e">
- [x] **多模态模型**:使用`gpt-4o`、`claude-3`等视觉模型,或`gpt-4-all`等逆向模型,完成图像、文件的识别分析。
- [x] **多模态模型**:使用`gpt-4o`、`claude-3`等视觉模型,或`gpt-4-all`等逆向模型,完成图像、文件的识别分析。
<img width="1443" alt="image" src="https://github.com/vastxie/99AI/assets/24899308/e1f1ed62-97e5-4412-9b72-5916d2337fdc">
@ -68,47 +66,179 @@
## 版本说明
| 特性 | 稳定版 | 开发版 |
| :----------- | :------------------- | :------------------------------------------------------------- |
| **商用许可** | 支持商用 | 支持商用 |
| **源码状态** | 未编译,支持自由修改 | 已编译,代码不可二次开发 |
| **获取方式** | 公开项目 | 私有库,需赞助后获取 |
| **页面特性** | 单对话页面 | 包含更多功能页面(如独立的绘画页面、思维导图页面、分销页面等) |
| 特性 | 稳定版 | 开发版 |
| :----------- | :--------------------------------------------- | :--------------------------------------------------------- |
| **商用许可** | 支持商用 | 支持商用 |
| **源码状态** | 未编译,支持自由修改 | 已编译,代码不可二次开发 |
| **获取方式** | 公开项目 | 私有库,需赞助后获取 |
| **页面特性** | 单对话页面 | 包含更多功能页面(如独立的绘画页面、思维导图页面、分销页面等) |
## 部署指南
## 安装部署
请参考完整的 [部署文档](./DEPLOYMENT.md) 了解详细信息
安装文档可能不是非常详细,但绝对够用。如果在安装或配置中遇到任何问题,可询问 AI、通过 [issue](https://github.com/vastxie/99AI/issues) 反馈或交流群内提问题
部署文档可能不是非常详细,但绝对够用。如果在安装或配置中遇到任何问题,可询问 AI、通过 [issue](https://github.com/vastxie/99AI/issues) 反馈或交流群内提问题。
### Node.js 部署
## 项目开发
**1. 安装 Node.js 环境**
请参考完整的 [开发文档](./src/DEVELOPMENT.md) 了解详细的开发流程和指引
推荐使用 `nvm` (Node Version Manager) 来安装 Node.js
### 目录结构
- 首先,安装 `nvm`,你可以从 [nvm GitHub 仓库](https://github.com/nvm-sh/nvm) 找到安装指南。
```plaintext
99AI/
├── DEPLOYMENT.md # 部署文档
├── Dockerfile # Docker 配置文件
├── deploy.sh # 一键部署脚本
├── docker-compose.yml # Docker Compose 配置文件
├── dist/ # 打包后的静态资源与后端代码
├── logs/ # 日志存储目录
├── public/ # 前端公共静态资源
└── src/ # 源码目录
├── admin/ # 管理端(基于 Fantastic Admin Basic 构建)
├── chat/ # 用户端(用户对话页面)
├── service/ # 后端服务(基于 NestJS 构建的核心 API 服务)
└── build.sh # 一键打包脚本
- 按照仓库中的安装说明进行操作,安装完成后,可能需要添加环境变量或重启终端。
- 安装 Node.js 版本 18 或更高版本:
```shell
nvm install 18
nvm use 18
```
- 验证 Node.js 是否安装成功:
```shell
node -v
```
**2. 安装 PM2 / PNPMYARN**
- 使用 npm 安装 PM2
```shell
npm install pm2 -g
```
- 使用 npm 安装 pnpm
```shell
npm install -g pnpm
```
- 确认 `PM2``pnpm` 都已正确安装并且可以运行:
```
pm2 -v
pnpm -v
```
**3. 其他配置**
- 需配置 Redis 数据库以及新建一个 MySQL 数据库。
- 配置环境变量:
- 复制 `.env.example` 文件为 `.env`
- 根据需要修改 `.env` 文件中的配置项。
**4. 安装启动**
- 安装依赖:(若安装缓慢可尝试使用国内源)
```shell
pnpm install
```
- 启动进程:(默认使用 PM2 后台运行)
```
pnpm start
```
- 查看运行日志:
```shell
pnpm logs
```
- 项目默认在 `9520` 端口运行,也可在环境变量中自行修改。成功运行后可通过 `IP:端口` 访问,或者配置 Nginx 反向代理,通过域名访问。
### 脚本部署
**1. 部署方式及功能支持**
- **全新安装 99AI**
- 自动安装环境
- 拉取源码
- 安装依赖
- 使用 PM2 监控运行
- **更新与修改配置**
- 自动拉取更新
- 自动更新程序
- 自定义修改配置
- **卸载 99AI**
- **使用 Docker 部署**
- 自动安装环境
- 自定义配置
- **添加快捷执行脚本**
- 后续仅需在服务器执行 `99ai` 即可再次进入脚本
**2. Shell 执行脚本**
请在项目的根目录下执行以下命令:
```bash
./deploy.sh
```
或使用:
```bash
bash <(curl -sL https://js.kengro.cn/99ai/onekey-cn-99ai.sh)
```
### Docker 部署
**1. 安装 Docker 及 Docker-compose**
- 使用 [Docker 官网](https://www.docker.com/) 提供的一键安装链接安装 Docker 及 Docker-compose。
```bash
curl -fsSL https://get.docker.com | bash -s docker
```
- 也可以使用其他方式自行安装 Docker 及 Docker-compose。
**2. 服务管理**
- **后台启动服务**
```shell
docker-compose up -d
```
- **查看日志**
```shell
docker-compose logs
```
- **停止服务**
```shell
docker-compose down
```
- **重新构建并启动服务**
```shell
docker-compose up -d --build
```
## 项目管理
普通管理员,可以预览后台非敏感信息,默认不激活。请使用超级管理员账号登入后台,并及时修改密码。
- **管理端地址**`项目链接/admin`
- **普通管理员账号**`admin`(默认不激活)
- **超级管理员账号**`super`
- **密码**`123456`
## 学习交流
扫码添加微信备注 `99`,拉交流群。(不接受私聊技术咨询,有问题优先群内交流)
<img src="https://github.com/vastxie/99AI/assets/24899308/ee20578f-063d-48d8-bff6-85ac3e38fe60"
width="300" alt="WeChat QR code for joining the group">
<img src="https://github.com/vastxie/NineAIQuickDeploy/assets/24899308/ee20578f-063d-48d8-bff6-85ac3e38fe60" width="300">
## Star History

View File

@ -1,100 +0,0 @@
"use strict";
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (this && this.__metadata) || function (k, v) {
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};
var __param = (this && this.__param) || function (paramIndex, decorator) {
return function (target, key) { decorator(target, key, paramIndex); }
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.BadWordsController = void 0;
const adminAuth_guard_1 = require("../../common/auth/adminAuth.guard");
const superAuth_guard_1 = require("../../common/auth/superAuth.guard");
const common_1 = require("@nestjs/common");
const swagger_1 = require("@nestjs/swagger");
const badWords_service_1 = require("./badWords.service");
const addBadWords_dto_1 = require("./dto/addBadWords.dto");
const delBadWords_dto_1 = require("./dto/delBadWords.dto");
const queryBadWords_dto_1 = require("./dto/queryBadWords.dto");
const queryViolation_dto_1 = require("./dto/queryViolation.dto");
const updateBadWords_dto_1 = require("./dto/updateBadWords.dto");
let BadWordsController = class BadWordsController {
constructor(badWordsService) {
this.badWordsService = badWordsService;
}
queryBadWords(query) {
return this.badWordsService.queryBadWords(query);
}
delBadWords(body) {
return this.badWordsService.delBadWords(body);
}
updateBadWords(body) {
return this.badWordsService.updateBadWords(body);
}
addBadWord(body) {
return this.badWordsService.addBadWord(body);
}
violation(req, query) {
return this.badWordsService.violation(req, query);
}
};
__decorate([
(0, common_1.Get)('query'),
(0, swagger_1.ApiOperation)({ summary: '查询所有敏感词' }),
__param(0, (0, common_1.Query)()),
__metadata("design:type", Function),
__metadata("design:paramtypes", [queryBadWords_dto_1.QueryBadWordsDto]),
__metadata("design:returntype", void 0)
], BadWordsController.prototype, "queryBadWords", null);
__decorate([
(0, common_1.Post)('del'),
(0, swagger_1.ApiOperation)({ summary: '删除敏感词' }),
(0, common_1.UseGuards)(superAuth_guard_1.SuperAuthGuard),
(0, swagger_1.ApiBearerAuth)(),
__param(0, (0, common_1.Body)()),
__metadata("design:type", Function),
__metadata("design:paramtypes", [delBadWords_dto_1.DelBadWordsDto]),
__metadata("design:returntype", void 0)
], BadWordsController.prototype, "delBadWords", null);
__decorate([
(0, common_1.Post)('update'),
(0, swagger_1.ApiOperation)({ summary: '更新敏感词' }),
(0, common_1.UseGuards)(superAuth_guard_1.SuperAuthGuard),
(0, swagger_1.ApiBearerAuth)(),
__param(0, (0, common_1.Body)()),
__metadata("design:type", Function),
__metadata("design:paramtypes", [updateBadWords_dto_1.UpdateBadWordsDto]),
__metadata("design:returntype", void 0)
], BadWordsController.prototype, "updateBadWords", null);
__decorate([
(0, common_1.Post)('add'),
(0, swagger_1.ApiOperation)({ summary: '新增敏感词' }),
(0, common_1.UseGuards)(superAuth_guard_1.SuperAuthGuard),
(0, swagger_1.ApiBearerAuth)(),
__param(0, (0, common_1.Body)()),
__metadata("design:type", Function),
__metadata("design:paramtypes", [addBadWords_dto_1.AddBadWordDto]),
__metadata("design:returntype", void 0)
], BadWordsController.prototype, "addBadWord", null);
__decorate([
(0, common_1.Get)('violation'),
(0, swagger_1.ApiOperation)({ summary: '查询违规记录' }),
(0, common_1.UseGuards)(adminAuth_guard_1.AdminAuthGuard),
(0, swagger_1.ApiBearerAuth)(),
__param(0, (0, common_1.Req)()),
__param(1, (0, common_1.Query)()),
__metadata("design:type", Function),
__metadata("design:paramtypes", [Object, queryViolation_dto_1.QueryViolationDto]),
__metadata("design:returntype", void 0)
], BadWordsController.prototype, "violation", null);
BadWordsController = __decorate([
(0, swagger_1.ApiTags)('badWords'),
(0, common_1.Controller)('badWords'),
__metadata("design:paramtypes", [badWords_service_1.BadWordsService])
], BadWordsController);
exports.BadWordsController = BadWordsController;

View File

@ -1,32 +0,0 @@
"use strict";
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (this && this.__metadata) || function (k, v) {
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.BadWordsEntity = void 0;
const baseEntity_1 = require("../../common/entity/baseEntity");
const typeorm_1 = require("typeorm");
let BadWordsEntity = class BadWordsEntity extends baseEntity_1.BaseEntity {
};
__decorate([
(0, typeorm_1.Column)({ length: 20, comment: '敏感词' }),
__metadata("design:type", String)
], BadWordsEntity.prototype, "word", void 0);
__decorate([
(0, typeorm_1.Column)({ default: 1, comment: '敏感词开启状态' }),
__metadata("design:type", Number)
], BadWordsEntity.prototype, "status", void 0);
__decorate([
(0, typeorm_1.Column)({ default: 0, comment: '敏感词触发次数' }),
__metadata("design:type", Number)
], BadWordsEntity.prototype, "count", void 0);
BadWordsEntity = __decorate([
(0, typeorm_1.Entity)({ name: 'bad_words' })
], BadWordsEntity);
exports.BadWordsEntity = BadWordsEntity;

View File

@ -1,30 +0,0 @@
"use strict";
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
return c > 3 && r && Object.defineProperty(target, key, r), r;
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.BadWordsModule = void 0;
const common_1 = require("@nestjs/common");
const typeorm_1 = require("@nestjs/typeorm");
const user_entity_1 = require("../user/user.entity");
const badWords_controller_1 = require("./badWords.controller");
const badWords_entity_1 = require("./badWords.entity");
const badWords_service_1 = require("./badWords.service");
const violationLog_entity_1 = require("./violationLog.entity");
let BadWordsModule = class BadWordsModule {
};
BadWordsModule = __decorate([
(0, common_1.Global)(),
(0, common_1.Module)({
imports: [
typeorm_1.TypeOrmModule.forFeature([badWords_entity_1.BadWordsEntity, violationLog_entity_1.ViolationLogEntity, user_entity_1.UserEntity]),
],
providers: [badWords_service_1.BadWordsService],
controllers: [badWords_controller_1.BadWordsController],
exports: [badWords_service_1.BadWordsService],
})
], BadWordsModule);
exports.BadWordsModule = BadWordsModule;

View File

@ -1,208 +0,0 @@
"use strict";
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (this && this.__metadata) || function (k, v) {
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};
var __param = (this && this.__param) || function (paramIndex, decorator) {
return function (target, key) { decorator(target, key, paramIndex); }
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.BadWordsService = void 0;
const utils_1 = require("../../common/utils");
const common_1 = require("@nestjs/common");
const typeorm_1 = require("@nestjs/typeorm");
const axios_1 = require("axios");
const typeorm_2 = require("typeorm");
const globalConfig_service_1 = require("../globalConfig/globalConfig.service");
const user_entity_1 = require("../user/user.entity");
const badWords_entity_1 = require("./badWords.entity");
const violationLog_entity_1 = require("./violationLog.entity");
let BadWordsService = class BadWordsService {
constructor(badWordsEntity, violationLogEntity, userEntity, globalConfigService) {
this.badWordsEntity = badWordsEntity;
this.violationLogEntity = violationLogEntity;
this.userEntity = userEntity;
this.globalConfigService = globalConfigService;
this.badWords = [];
}
async onModuleInit() {
this.loadBadWords();
}
async customSensitiveWords(content, userId) {
const triggeredWords = [];
for (let i = 0; i < this.badWords.length; i++) {
const word = this.badWords[i];
if (content.includes(word)) {
triggeredWords.push(word);
}
}
if (triggeredWords.length) {
await this.recordUserBadWords(userId, content, triggeredWords, ['自定义'], '自定义检测');
}
return triggeredWords;
}
async checkBadWords(content, userId) {
const config = await this.globalConfigService.getSensitiveConfig();
if (config) {
await this.checkBadWordsByConfig(content, config, userId);
}
return await this.customSensitiveWords(content, userId);
}
async checkBadWordsByConfig(content, config, userId) {
const { useType } = config;
useType === 'baidu' &&
(await this.baiduCheckBadWords(content, config.baiduTextAccessToken, userId));
}
extractContent(str) {
const pattern = /存在(.*?)不合规/;
const match = str.match(pattern);
return match ? match[1] : '';
}
async baiduCheckBadWords(content, accessToken, userId) {
if (!accessToken)
return;
const url = `https://aip.baidubce.com/rest/2.0/solution/v1/text_censor/v2/user_defined?access_token=${accessToken}}`;
const headers = {
'Content-Type': 'application/x-www-form-urlencoded',
Accept: 'application/json',
};
const response = await axios_1.default.post(url, { text: content }, { headers });
const { conclusion, error_code, error_msg, conclusionType, data } = response.data;
if (error_code) {
console.log('百度文本检测出现错误、请查看配置信息: ', error_msg);
}
if (conclusionType !== 1) {
const types = [
...new Set(data.map((item) => this.extractContent(item.msg))),
];
await this.recordUserBadWords(userId, content, ['***'], types, '百度云检测');
const tips = `您提交的信息中包含${types.join(',')}的内容、我们已对您的账户进行标记、请合规使用!`;
throw new common_1.HttpException(tips, common_1.HttpStatus.BAD_REQUEST);
}
}
formarTips(wordList) {
const categorys = wordList.map((t) => t.category);
const unSet = [...new Set(categorys)];
return `您提交的内容中包含${unSet.join(',')}的信息、我们已对您账号进行标记、请合规使用!`;
}
async loadBadWords() {
const data = await this.badWordsEntity.find({
where: { status: 1 },
select: ['word'],
});
this.badWords = data.map((t) => t.word);
}
async queryBadWords(query) {
const { page = 1, size = 500, word, status } = query;
const where = {};
[0, 1, '0', '1'].includes(status) && (where.status = status);
word && (where.word = (0, typeorm_2.Like)(`%${word}%`));
const [rows, count] = await this.badWordsEntity.findAndCount({
where,
skip: (page - 1) * size,
take: size,
order: { id: 'ASC' },
});
return { rows, count };
}
async delBadWords(body) {
const b = await this.badWordsEntity.findOne({ where: { id: body.id } });
if (!b) {
throw new common_1.HttpException('敏感词不存在,请检查您的提交信息', common_1.HttpStatus.BAD_REQUEST);
}
const res = await this.badWordsEntity.delete({ id: body.id });
if (res.affected > 0) {
await this.loadBadWords();
return '删除敏感词成功';
}
else {
throw new common_1.HttpException('删除敏感词失败', common_1.HttpStatus.BAD_REQUEST);
}
}
async updateBadWords(body) {
const { id, word, status } = body;
const b = await this.badWordsEntity.findOne({ where: { word } });
if (b) {
throw new common_1.HttpException('敏感词已经存在了、请勿重复添加', common_1.HttpStatus.BAD_REQUEST);
}
const res = await this.badWordsEntity.update({ id }, { word, status });
if (res.affected > 0) {
await this.loadBadWords();
return '更新敏感词成功';
}
else {
throw new common_1.HttpException('更新敏感词失败', common_1.HttpStatus.BAD_REQUEST);
}
}
async addBadWord(body) {
const { word } = body;
const b = await this.badWordsEntity.findOne({ where: { word } });
if (b) {
throw new common_1.HttpException('敏感词已存在,请检查您的提交信息', common_1.HttpStatus.BAD_REQUEST);
}
await this.badWordsEntity.save({ word });
await this.loadBadWords();
return '添加敏感词成功';
}
async recordUserBadWords(userId, content, words, typeCn, typeOriginCn) {
const data = {
userId,
content,
words: JSON.stringify(words),
typeCn: JSON.stringify(typeCn),
typeOriginCn,
};
try {
await this.userEntity
.createQueryBuilder()
.update(user_entity_1.UserEntity)
.set({ violationCount: () => 'violationCount + 1' })
.where('id = :userId', { userId })
.execute();
await this.violationLogEntity.save(data);
}
catch (error) {
console.log('error: ', error);
}
}
async violation(req, query) {
const { role } = req.user;
const { page = 1, size = 10, userId, typeOriginCn } = query;
const where = {};
userId && (where['userId'] = userId);
typeOriginCn && (where['typeOriginCn'] = typeOriginCn);
const [rows, count] = await this.violationLogEntity.findAndCount({
where,
skip: (page - 1) * size,
take: size,
order: { id: 'DESC' },
});
const userIds = [...new Set(rows.map((t) => t.userId))];
const usersInfo = await this.userEntity.find({
where: { id: (0, typeorm_2.In)(userIds) },
select: ['id', 'avatar', 'username', 'email', 'violationCount', 'status'],
});
rows.forEach((t) => {
const user = usersInfo.find((u) => u.id === t.userId) || {};
role !== 'super' && (user.email = (0, utils_1.hideString)(user.email));
t.userInfo = user;
});
return { rows, count };
}
};
BadWordsService = __decorate([
(0, common_1.Injectable)(),
__param(0, (0, typeorm_1.InjectRepository)(badWords_entity_1.BadWordsEntity)),
__param(1, (0, typeorm_1.InjectRepository)(violationLog_entity_1.ViolationLogEntity)),
__param(2, (0, typeorm_1.InjectRepository)(user_entity_1.UserEntity)),
__metadata("design:paramtypes", [typeorm_2.Repository,
typeorm_2.Repository,
typeorm_2.Repository,
globalConfig_service_1.GlobalConfigService])
], BadWordsService);
exports.BadWordsService = BadWordsService;

View File

@ -1,20 +0,0 @@
"use strict";
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (this && this.__metadata) || function (k, v) {
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.AddBadWordDto = void 0;
const swagger_1 = require("@nestjs/swagger");
class AddBadWordDto {
}
__decorate([
(0, swagger_1.ApiProperty)({ example: 'test', description: '敏感词', required: true }),
__metadata("design:type", String)
], AddBadWordDto.prototype, "word", void 0);
exports.AddBadWordDto = AddBadWordDto;

View File

@ -1,20 +0,0 @@
"use strict";
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (this && this.__metadata) || function (k, v) {
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.DelBadWordsDto = void 0;
const swagger_1 = require("@nestjs/swagger");
class DelBadWordsDto {
}
__decorate([
(0, swagger_1.ApiProperty)({ example: 1, description: '敏感词id', required: true }),
__metadata("design:type", Number)
], DelBadWordsDto.prototype, "id", void 0);
exports.DelBadWordsDto = DelBadWordsDto;

View File

@ -1,37 +0,0 @@
"use strict";
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (this && this.__metadata) || function (k, v) {
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.QueryBadWordsDto = void 0;
const class_validator_1 = require("class-validator");
const swagger_1 = require("@nestjs/swagger");
class QueryBadWordsDto {
}
__decorate([
(0, swagger_1.ApiProperty)({ example: 1, description: '查询页数', required: false }),
(0, class_validator_1.IsOptional)(),
__metadata("design:type", Number)
], QueryBadWordsDto.prototype, "page", void 0);
__decorate([
(0, swagger_1.ApiProperty)({ example: 10, description: '每页数量', required: false }),
(0, class_validator_1.IsOptional)(),
__metadata("design:type", Number)
], QueryBadWordsDto.prototype, "size", void 0);
__decorate([
(0, swagger_1.ApiProperty)({ example: 'test', description: '敏感词内容', required: false }),
(0, class_validator_1.IsOptional)(),
__metadata("design:type", String)
], QueryBadWordsDto.prototype, "word", void 0);
__decorate([
(0, swagger_1.ApiProperty)({ example: 1, description: '关键词状态', required: false }),
(0, class_validator_1.IsOptional)(),
__metadata("design:type", Number)
], QueryBadWordsDto.prototype, "status", void 0);
exports.QueryBadWordsDto = QueryBadWordsDto;

View File

@ -1,37 +0,0 @@
"use strict";
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (this && this.__metadata) || function (k, v) {
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.QueryViolationDto = void 0;
const class_validator_1 = require("class-validator");
const swagger_1 = require("@nestjs/swagger");
class QueryViolationDto {
}
__decorate([
(0, swagger_1.ApiProperty)({ example: 1, description: '查询页数', required: false }),
(0, class_validator_1.IsOptional)(),
__metadata("design:type", Number)
], QueryViolationDto.prototype, "page", void 0);
__decorate([
(0, swagger_1.ApiProperty)({ example: 10, description: '每页数量', required: false }),
(0, class_validator_1.IsOptional)(),
__metadata("design:type", Number)
], QueryViolationDto.prototype, "size", void 0);
__decorate([
(0, swagger_1.ApiProperty)({ example: 1, description: '用户ID', required: false }),
(0, class_validator_1.IsOptional)(),
__metadata("design:type", Number)
], QueryViolationDto.prototype, "userId", void 0);
__decorate([
(0, swagger_1.ApiProperty)({ example: '百度云检测', description: '检测平台来源', required: false }),
(0, class_validator_1.IsOptional)(),
__metadata("design:type", String)
], QueryViolationDto.prototype, "typeOriginCn", void 0);
exports.QueryViolationDto = QueryViolationDto;

View File

@ -1,32 +0,0 @@
"use strict";
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (this && this.__metadata) || function (k, v) {
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.UpdateBadWordsDto = void 0;
const class_validator_1 = require("class-validator");
const swagger_1 = require("@nestjs/swagger");
class UpdateBadWordsDto {
}
__decorate([
(0, swagger_1.ApiProperty)({ example: 1, description: '敏感词id', required: true }),
(0, class_validator_1.IsOptional)(),
__metadata("design:type", Number)
], UpdateBadWordsDto.prototype, "id", void 0);
__decorate([
(0, swagger_1.ApiProperty)({ example: 'test', description: '敏感词内容', required: false }),
(0, class_validator_1.IsOptional)(),
__metadata("design:type", String)
], UpdateBadWordsDto.prototype, "word", void 0);
__decorate([
(0, swagger_1.ApiProperty)({ example: 1, description: '关键词状态', required: false }),
(0, class_validator_1.IsOptional)(),
__metadata("design:type", Number)
], UpdateBadWordsDto.prototype, "status", void 0);
exports.UpdateBadWordsDto = UpdateBadWordsDto;

View File

@ -1,40 +0,0 @@
"use strict";
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (this && this.__metadata) || function (k, v) {
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.ViolationLogEntity = void 0;
const typeorm_1 = require("typeorm");
const baseEntity_1 = require("../../common/entity/baseEntity");
let ViolationLogEntity = class ViolationLogEntity extends baseEntity_1.BaseEntity {
};
__decorate([
(0, typeorm_1.Column)({ comment: '用户id' }),
__metadata("design:type", Number)
], ViolationLogEntity.prototype, "userId", void 0);
__decorate([
(0, typeorm_1.Column)({ comment: '违规内容', type: 'text' }),
__metadata("design:type", String)
], ViolationLogEntity.prototype, "content", void 0);
__decorate([
(0, typeorm_1.Column)({ comment: '敏感词', type: 'text' }),
__metadata("design:type", String)
], ViolationLogEntity.prototype, "words", void 0);
__decorate([
(0, typeorm_1.Column)({ comment: '违规类型' }),
__metadata("design:type", String)
], ViolationLogEntity.prototype, "typeCn", void 0);
__decorate([
(0, typeorm_1.Column)({ comment: '违规检测失败于哪个平台' }),
__metadata("design:type", String)
], ViolationLogEntity.prototype, "typeOriginCn", void 0);
ViolationLogEntity = __decorate([
(0, typeorm_1.Entity)({ name: 'violation_log' })
], ViolationLogEntity);
exports.ViolationLogEntity = ViolationLogEntity;

View File

@ -31,7 +31,6 @@ services:
99ai:
build: ./
# image: vastxie/99ai:latest
container_name: 99ai
restart: always
ports:

View File

@ -1,58 +0,0 @@
# 99AI 项目开发指引
## 项目结构
```plaintext
src/
├── admin/ # 管理端
├── chat/ # 用户端(对话页)
├── service/ # 后端服务
└── build.sh # 一键打包脚本
```
---
## 模块说明
### 1. 用户端chat
- **位置:** `src/chat`
- **功能:**
- 使用 Vue.js 构建。
- 支持 AI 对话、多模态分析、文件上传与解析等用户功能。
---
### 2. 管理端admin
- **位置:** `src/admin`
- **功能:**
- 基于 [Fantastic Admin Basic](https://github.com/fantastic-admin/basic) 开源框架构建。
- 超级管理员和普通管理员的后台管理页面。
- 支持积分系统管理、模型配置、用户管理等功能。
---
### 3. 后端服务service
- **位置:** `src/service`
- **功能:**
- 提供 API 接口,负责模型调用、业务逻辑处理与数据库交互。
- 支持多模态模型、文件分析、用户积分系统等功能。
- 使用 NestJS 构建,默认运行在 `http://localhost:9520`
---
## 一键打包脚本
项目提供了 `build.sh` 脚本,用于快速打包整个项目:
```bash
bash build.sh
```
执行后,所有模块将自动构建,构建后的文件存放在项目根目录的文件夹中。
---
如有其他问题,请查看项目根目录的文档或通过 [issue](https://github.com/vastxie/99AI/issues) 提交反馈。

View File

@ -9,8 +9,10 @@ import { NestFactory } from '@nestjs/core';
import * as compression from 'compression';
import { randomBytes } from 'crypto';
import * as Dotenv from 'dotenv';
// import * as express from 'express';
import * as xmlBodyParser from 'express-xml-bodyparser';
import Redis from 'ioredis';
// import { join } from 'path';
import { AppModule } from './app.module';
Dotenv.config({ path: '.env' });