diff --git a/.github/workflows/sync_imgs.yml b/.github/workflows/docs-sync_imgs.yml similarity index 100% rename from .github/workflows/sync_imgs.yml rename to .github/workflows/docs-sync_imgs.yml diff --git a/.github/workflows/fastgpt-image-personal.yml b/.github/workflows/fastgpt-build-image-personal.yml similarity index 100% rename from .github/workflows/fastgpt-image-personal.yml rename to .github/workflows/fastgpt-build-image-personal.yml diff --git a/.github/workflows/fastgpt-image.yml b/.github/workflows/fastgpt-build-image.yml similarity index 100% rename from .github/workflows/fastgpt-image.yml rename to .github/workflows/fastgpt-build-image.yml diff --git a/.github/workflows/preview-fastgpt-image.yml b/.github/workflows/fastgpt-preview-image.yml similarity index 100% rename from .github/workflows/preview-fastgpt-image.yml rename to .github/workflows/fastgpt-preview-image.yml diff --git a/.github/workflows/build-sandbox-image.yml b/.github/workflows/sandbox-build-image.yml similarity index 100% rename from .github/workflows/build-sandbox-image.yml rename to .github/workflows/sandbox-build-image.yml diff --git a/files/docker/docker-compose-milvus.yml b/deploy/docker/docker-compose-milvus.yml similarity index 100% rename from files/docker/docker-compose-milvus.yml rename to deploy/docker/docker-compose-milvus.yml diff --git a/files/docker/docker-compose-pgvector.yml b/deploy/docker/docker-compose-pgvector.yml similarity index 100% rename from files/docker/docker-compose-pgvector.yml rename to deploy/docker/docker-compose-pgvector.yml diff --git a/files/docker/docker-compose-zilliz.yml b/deploy/docker/docker-compose-zilliz.yml similarity index 100% rename from files/docker/docker-compose-zilliz.yml rename to deploy/docker/docker-compose-zilliz.yml diff --git a/files/docker/docker-compose/docker-compose b/deploy/docker/docker-compose/docker-compose similarity index 100% rename from files/docker/docker-compose/docker-compose rename to deploy/docker/docker-compose/docker-compose diff --git a/files/docker/docker-compose/init.sh b/deploy/docker/docker-compose/init.sh similarity index 100% rename from files/docker/docker-compose/init.sh rename to deploy/docker/docker-compose/init.sh diff --git a/files/docker/run.sh b/deploy/docker/run.sh similarity index 100% rename from files/docker/run.sh rename to deploy/docker/run.sh diff --git a/files/helm/fastgpt/.helmignore b/deploy/helm/fastgpt/.helmignore similarity index 100% rename from files/helm/fastgpt/.helmignore rename to deploy/helm/fastgpt/.helmignore diff --git a/files/helm/fastgpt/Chart.lock b/deploy/helm/fastgpt/Chart.lock similarity index 100% rename from files/helm/fastgpt/Chart.lock rename to deploy/helm/fastgpt/Chart.lock diff --git a/files/helm/fastgpt/Chart.yaml b/deploy/helm/fastgpt/Chart.yaml similarity index 100% rename from files/helm/fastgpt/Chart.yaml rename to deploy/helm/fastgpt/Chart.yaml diff --git a/files/helm/fastgpt/README.md b/deploy/helm/fastgpt/README.md similarity index 100% rename from files/helm/fastgpt/README.md rename to deploy/helm/fastgpt/README.md diff --git a/files/helm/fastgpt/templates/NOTES.txt b/deploy/helm/fastgpt/templates/NOTES.txt similarity index 100% rename from files/helm/fastgpt/templates/NOTES.txt rename to deploy/helm/fastgpt/templates/NOTES.txt diff --git a/files/helm/fastgpt/templates/_helpers.tpl b/deploy/helm/fastgpt/templates/_helpers.tpl similarity index 100% rename from files/helm/fastgpt/templates/_helpers.tpl rename to deploy/helm/fastgpt/templates/_helpers.tpl diff --git a/files/helm/fastgpt/templates/configmap-config.yaml b/deploy/helm/fastgpt/templates/configmap-config.yaml similarity index 100% rename from files/helm/fastgpt/templates/configmap-config.yaml rename to deploy/helm/fastgpt/templates/configmap-config.yaml diff --git a/files/helm/fastgpt/templates/deployment.yaml b/deploy/helm/fastgpt/templates/deployment.yaml similarity index 100% rename from files/helm/fastgpt/templates/deployment.yaml rename to deploy/helm/fastgpt/templates/deployment.yaml diff --git a/files/helm/fastgpt/templates/hpa.yaml b/deploy/helm/fastgpt/templates/hpa.yaml similarity index 100% rename from files/helm/fastgpt/templates/hpa.yaml rename to deploy/helm/fastgpt/templates/hpa.yaml diff --git a/files/helm/fastgpt/templates/ingress.yaml b/deploy/helm/fastgpt/templates/ingress.yaml similarity index 100% rename from files/helm/fastgpt/templates/ingress.yaml rename to deploy/helm/fastgpt/templates/ingress.yaml diff --git a/files/helm/fastgpt/templates/secret-env.yaml b/deploy/helm/fastgpt/templates/secret-env.yaml similarity index 100% rename from files/helm/fastgpt/templates/secret-env.yaml rename to deploy/helm/fastgpt/templates/secret-env.yaml diff --git a/files/helm/fastgpt/templates/service.yaml b/deploy/helm/fastgpt/templates/service.yaml similarity index 100% rename from files/helm/fastgpt/templates/service.yaml rename to deploy/helm/fastgpt/templates/service.yaml diff --git a/files/helm/fastgpt/templates/serviceaccount.yaml b/deploy/helm/fastgpt/templates/serviceaccount.yaml similarity index 100% rename from files/helm/fastgpt/templates/serviceaccount.yaml rename to deploy/helm/fastgpt/templates/serviceaccount.yaml diff --git a/files/helm/fastgpt/templates/tests/test-connection.yaml b/deploy/helm/fastgpt/templates/tests/test-connection.yaml similarity index 100% rename from files/helm/fastgpt/templates/tests/test-connection.yaml rename to deploy/helm/fastgpt/templates/tests/test-connection.yaml diff --git a/files/helm/fastgpt/values.yaml b/deploy/helm/fastgpt/values.yaml similarity index 100% rename from files/helm/fastgpt/values.yaml rename to deploy/helm/fastgpt/values.yaml diff --git a/docSite/content/zh-cn/docs/development/custom-models/bge-rerank.md b/docSite/content/zh-cn/docs/development/custom-models/bge-rerank.md index ef1f27ac7..1b9e3d133 100644 --- a/docSite/content/zh-cn/docs/development/custom-models/bge-rerank.md +++ b/docSite/content/zh-cn/docs/development/custom-models/bge-rerank.md @@ -31,9 +31,9 @@ weight: 920 3 个模型代码分别为: -1. [https://github.com/labring/FastGPT/tree/main/python/bge-rerank/bge-reranker-base](https://github.com/labring/FastGPT/tree/main/python/bge-rerank/bge-reranker-base) -2. [https://github.com/labring/FastGPT/tree/main/python/bge-rerank/bge-reranker-large](https://github.com/labring/FastGPT/tree/main/python/bge-rerank/bge-reranker-large) -3. [https://github.com/labring/FastGPT/tree/main/python/bge-rerank/bge-reranker-v2-m3](https://github.com/labring/FastGPT/tree/main/python/bge-rerank/bge-reranker-v2-m3) +1. [https://github.com/labring/FastGPT/tree/main/plugins/rerank-bge/bge-reranker-base](https://github.com/labring/FastGPT/tree/main/plugins/rerank-bge/bge-reranker-base) +2. [https://github.com/labring/FastGPT/tree/main/plugins/rerank-bge/bge-reranker-large](https://github.com/labring/FastGPT/tree/main/plugins/rerank-bge/bge-reranker-large) +3. [https://github.com/labring/FastGPT/tree/main/plugins/rerank-bge/bge-reranker-v2-m3](https://github.com/labring/FastGPT/tree/main/plugins/rerank-bge/bge-reranker-v2-m3) ### 3. 安装依赖 diff --git a/docSite/content/zh-cn/docs/development/custom-models/marker.md b/docSite/content/zh-cn/docs/development/custom-models/marker.md index ce68431a8..93c9d97bc 100644 --- a/docSite/content/zh-cn/docs/development/custom-models/marker.md +++ b/docSite/content/zh-cn/docs/development/custom-models/marker.md @@ -19,7 +19,7 @@ PDF 是一个相对复杂的文件格式,在 FastGPT 内置的 pdf 解析器 ### 1. 按照 Marker -参考文档 [Marker 安装教程](https://github.com/labring/FastGPT/tree/main/python/pdf-marker),安装 Marker 模型。封装的 API 已经适配了 FastGPT 自定义解析服务。 +参考文档 [Marker 安装教程](https://github.com/labring/FastGPT/tree/main/plugins/model/pdf-marker),安装 Marker 模型。封装的 API 已经适配了 FastGPT 自定义解析服务。 这里介绍快速 Docker 安装的方法: diff --git a/docSite/content/zh-cn/docs/development/docker.md b/docSite/content/zh-cn/docs/development/docker.md index 22be77625..61c2da847 100644 --- a/docSite/content/zh-cn/docs/development/docker.md +++ b/docSite/content/zh-cn/docs/development/docker.md @@ -118,7 +118,7 @@ brew install orbstack 非 Linux 环境或无法访问外网环境,可手动创建一个目录,并下载配置文件和对应版本的`docker-compose.yml`,在这个文件夹中依据下载的配置文件运行docker,若作为本地开发使用推荐`docker-compose-pgvector`版本,并且自行拉取并运行`sandbox`和`fastgpt`,并在docker配置文件中注释掉`sandbox`和`fastgpt`的部分 - [config.json](https://raw.githubusercontent.com/labring/FastGPT/refs/heads/main/projects/app/data/config.json) -- [docker-compose.yml](https://github.com/labring/FastGPT/blob/main/files/docker) (注意,不同向量库版本的文件不一样) +- [docker-compose.yml](https://github.com/labring/FastGPT/blob/main/deploy/docker) (注意,不同向量库版本的文件不一样) {{% alert icon="🤖" context="success" %}} @@ -134,11 +134,11 @@ cd fastgpt curl -O https://raw.githubusercontent.com/labring/FastGPT/main/projects/app/data/config.json # pgvector 版本(测试推荐,简单快捷) -curl -o docker-compose.yml https://raw.githubusercontent.com/labring/FastGPT/main/files/docker/docker-compose-pgvector.yml +curl -o docker-compose.yml https://raw.githubusercontent.com/labring/FastGPT/main/deploy/docker/docker-compose-pgvector.yml # milvus 版本 -# curl -o docker-compose.yml https://raw.githubusercontent.com/labring/FastGPT/main/files/docker/docker-compose-milvus.yml +# curl -o docker-compose.yml https://raw.githubusercontent.com/labring/FastGPT/main/deploy/docker/docker-compose-milvus.yml # zilliz 版本 -# curl -o docker-compose.yml https://raw.githubusercontent.com/labring/FastGPT/main/files/docker/docker-compose-zilliz.yml +# curl -o docker-compose.yml https://raw.githubusercontent.com/labring/FastGPT/main/deploy/docker/docker-compose-zilliz.yml ``` ### 2. 修改环境变量 diff --git a/docSite/content/zh-cn/docs/development/upgrading/482.md b/docSite/content/zh-cn/docs/development/upgrading/482.md index f50d22dd9..f59ba31fb 100644 --- a/docSite/content/zh-cn/docs/development/upgrading/482.md +++ b/docSite/content/zh-cn/docs/development/upgrading/482.md @@ -20,7 +20,7 @@ SANDBOX_URL=内网地址 ## Docker 部署 -可以拉取最新 [docker-compose.yml](https://github.com/labring/FastGPT/blob/main/files/docker/docker-compose.yml) 文件参考 +可以拉取最新 [docker-compose.yml](https://github.com/labring/FastGPT/blob/main/deploy/docker/docker-compose.yml) 文件参考 1. 新增一个容器 `sandbox` 2. fastgpt 和 fastgpt-pro(商业版) 容器新增环境变量: `SANDBOX_URL` diff --git a/docSite/content/zh-cn/docs/development/upgrading/483.md b/docSite/content/zh-cn/docs/development/upgrading/483.md index 81f30a950..924b4db8e 100644 --- a/docSite/content/zh-cn/docs/development/upgrading/483.md +++ b/docSite/content/zh-cn/docs/development/upgrading/483.md @@ -15,7 +15,7 @@ weight: 821 ## V4.8.3 更新说明 -1. 新增 - 支持 Milvus 数据库, 可参考最新的 [docker-compose-milvus.yml](https://github.com/labring/FastGPT/blob/main/files/docker/docker-compose-milvus.yml). +1. 新增 - 支持 Milvus 数据库, 可参考最新的 [docker-compose-milvus.yml](https://github.com/labring/FastGPT/blob/main/deploy/docker/docker-compose-milvus.yml). 2. 新增 - 给 chat 接口 empty answer 增加 log,便于排查模型问题。 3. 新增 - ifelse判断器,字符串支持正则。 4. 新增 - 代码运行支持 console.log 输出调试。 diff --git a/packages/README.md b/packages/README.md new file mode 100644 index 000000000..13253ba05 --- /dev/null +++ b/packages/README.md @@ -0,0 +1,3 @@ +# 目录说明 + +该目录为 FastGPT 的依赖包,多端复用。 diff --git a/plugins/README.md b/plugins/README.md new file mode 100644 index 000000000..9d2defe87 --- /dev/null +++ b/plugins/README.md @@ -0,0 +1,5 @@ +# 目录说明 + +该目录为 FastGPT 辅助子项目,非必须。 + +- model 私有化模型 \ No newline at end of file diff --git a/files/models/Baichuan2/openai_api.py b/plugins/model/llm-Baichuan2/openai_api.py similarity index 100% rename from files/models/Baichuan2/openai_api.py rename to plugins/model/llm-Baichuan2/openai_api.py diff --git a/files/models/Baichuan2/requirements.txt b/plugins/model/llm-Baichuan2/requirements.txt similarity index 100% rename from files/models/Baichuan2/requirements.txt rename to plugins/model/llm-Baichuan2/requirements.txt diff --git a/files/models/ChatGLM2/openai_api.py b/plugins/model/llm-ChatGLM2/openai_api.py similarity index 100% rename from files/models/ChatGLM2/openai_api.py rename to plugins/model/llm-ChatGLM2/openai_api.py diff --git a/files/models/ChatGLM2/requirements.txt b/plugins/model/llm-ChatGLM2/requirements.txt similarity index 100% rename from files/models/ChatGLM2/requirements.txt rename to plugins/model/llm-ChatGLM2/requirements.txt diff --git a/python/ocr/surya/Dockerfile b/plugins/model/ocr-surya/Dockerfile similarity index 100% rename from python/ocr/surya/Dockerfile rename to plugins/model/ocr-surya/Dockerfile diff --git a/python/ocr/surya/README.md b/plugins/model/ocr-surya/README.md similarity index 100% rename from python/ocr/surya/README.md rename to plugins/model/ocr-surya/README.md diff --git a/python/ocr/surya/app.py b/plugins/model/ocr-surya/app.py similarity index 100% rename from python/ocr/surya/app.py rename to plugins/model/ocr-surya/app.py diff --git a/python/ocr/surya/requirements.txt b/plugins/model/ocr-surya/requirements.txt similarity index 100% rename from python/ocr/surya/requirements.txt rename to plugins/model/ocr-surya/requirements.txt diff --git a/python/pdf-marker/Dockerfile b/plugins/model/pdf-marker/Dockerfile similarity index 100% rename from python/pdf-marker/Dockerfile rename to plugins/model/pdf-marker/Dockerfile diff --git a/python/pdf-marker/Readme.md b/plugins/model/pdf-marker/Readme.md similarity index 100% rename from python/pdf-marker/Readme.md rename to plugins/model/pdf-marker/Readme.md diff --git a/python/pdf-marker/api_mp.py b/plugins/model/pdf-marker/api_mp.py similarity index 100% rename from python/pdf-marker/api_mp.py rename to plugins/model/pdf-marker/api_mp.py diff --git a/python/pdf-marker/pip.conf b/plugins/model/pdf-marker/pip.conf similarity index 100% rename from python/pdf-marker/pip.conf rename to plugins/model/pdf-marker/pip.conf diff --git a/python/pdf-marker/requirements.txt b/plugins/model/pdf-marker/requirements.txt similarity index 100% rename from python/pdf-marker/requirements.txt rename to plugins/model/pdf-marker/requirements.txt diff --git a/python/pdf-marker/test/test.py b/plugins/model/pdf-marker/test/test.py similarity index 100% rename from python/pdf-marker/test/test.py rename to plugins/model/pdf-marker/test/test.py diff --git a/python/bge-rerank/README.md b/plugins/model/rerank-bge/README.md similarity index 100% rename from python/bge-rerank/README.md rename to plugins/model/rerank-bge/README.md diff --git a/python/bge-rerank/bge-reranker-base/Dockerfile b/plugins/model/rerank-bge/bge-reranker-base/Dockerfile similarity index 100% rename from python/bge-rerank/bge-reranker-base/Dockerfile rename to plugins/model/rerank-bge/bge-reranker-base/Dockerfile diff --git a/python/bge-rerank/bge-reranker-base/app.py b/plugins/model/rerank-bge/bge-reranker-base/app.py similarity index 100% rename from python/bge-rerank/bge-reranker-base/app.py rename to plugins/model/rerank-bge/bge-reranker-base/app.py diff --git a/python/bge-rerank/bge-reranker-base/requirements.txt b/plugins/model/rerank-bge/bge-reranker-base/requirements.txt similarity index 100% rename from python/bge-rerank/bge-reranker-base/requirements.txt rename to plugins/model/rerank-bge/bge-reranker-base/requirements.txt diff --git a/python/bge-rerank/bge-reranker-large/Dockerfile b/plugins/model/rerank-bge/bge-reranker-large/Dockerfile similarity index 100% rename from python/bge-rerank/bge-reranker-large/Dockerfile rename to plugins/model/rerank-bge/bge-reranker-large/Dockerfile diff --git a/python/bge-rerank/bge-reranker-large/app.py b/plugins/model/rerank-bge/bge-reranker-large/app.py similarity index 100% rename from python/bge-rerank/bge-reranker-large/app.py rename to plugins/model/rerank-bge/bge-reranker-large/app.py diff --git a/python/bge-rerank/bge-reranker-large/requirements.txt b/plugins/model/rerank-bge/bge-reranker-large/requirements.txt similarity index 100% rename from python/bge-rerank/bge-reranker-large/requirements.txt rename to plugins/model/rerank-bge/bge-reranker-large/requirements.txt diff --git a/python/bge-rerank/bge-reranker-v2-m3/Dockerfile b/plugins/model/rerank-bge/bge-reranker-v2-m3/Dockerfile similarity index 100% rename from python/bge-rerank/bge-reranker-v2-m3/Dockerfile rename to plugins/model/rerank-bge/bge-reranker-v2-m3/Dockerfile diff --git a/python/bge-rerank/bge-reranker-v2-m3/app.py b/plugins/model/rerank-bge/bge-reranker-v2-m3/app.py similarity index 100% rename from python/bge-rerank/bge-reranker-v2-m3/app.py rename to plugins/model/rerank-bge/bge-reranker-v2-m3/app.py diff --git a/python/bge-rerank/bge-reranker-v2-m3/requirements.txt b/plugins/model/rerank-bge/bge-reranker-v2-m3/requirements.txt similarity index 100% rename from python/bge-rerank/bge-reranker-v2-m3/requirements.txt rename to plugins/model/rerank-bge/bge-reranker-v2-m3/requirements.txt diff --git a/python/bge-rerank/rerank1.png b/plugins/model/rerank-bge/rerank1.png similarity index 100% rename from python/bge-rerank/rerank1.png rename to plugins/model/rerank-bge/rerank1.png diff --git a/python/sensevoice/Dockerfile b/plugins/model/stt-sensevoice/Dockerfile similarity index 100% rename from python/sensevoice/Dockerfile rename to plugins/model/stt-sensevoice/Dockerfile diff --git a/python/sensevoice/app/=1.13 b/plugins/model/stt-sensevoice/app/=1.13 similarity index 100% rename from python/sensevoice/app/=1.13 rename to plugins/model/stt-sensevoice/app/=1.13 diff --git a/python/sensevoice/app/iic/SenseVoiceSmall/.mdl b/plugins/model/stt-sensevoice/app/iic/SenseVoiceSmall/.mdl similarity index 100% rename from python/sensevoice/app/iic/SenseVoiceSmall/.mdl rename to plugins/model/stt-sensevoice/app/iic/SenseVoiceSmall/.mdl diff --git a/python/sensevoice/app/iic/SenseVoiceSmall/.msc b/plugins/model/stt-sensevoice/app/iic/SenseVoiceSmall/.msc similarity index 100% rename from python/sensevoice/app/iic/SenseVoiceSmall/.msc rename to plugins/model/stt-sensevoice/app/iic/SenseVoiceSmall/.msc diff --git a/python/sensevoice/app/iic/SenseVoiceSmall/.mv b/plugins/model/stt-sensevoice/app/iic/SenseVoiceSmall/.mv similarity index 100% rename from python/sensevoice/app/iic/SenseVoiceSmall/.mv rename to plugins/model/stt-sensevoice/app/iic/SenseVoiceSmall/.mv diff --git a/python/sensevoice/app/iic/SenseVoiceSmall/README.md b/plugins/model/stt-sensevoice/app/iic/SenseVoiceSmall/README.md similarity index 100% rename from python/sensevoice/app/iic/SenseVoiceSmall/README.md rename to plugins/model/stt-sensevoice/app/iic/SenseVoiceSmall/README.md diff --git a/python/sensevoice/app/iic/SenseVoiceSmall/am.mvn b/plugins/model/stt-sensevoice/app/iic/SenseVoiceSmall/am.mvn similarity index 100% rename from python/sensevoice/app/iic/SenseVoiceSmall/am.mvn rename to plugins/model/stt-sensevoice/app/iic/SenseVoiceSmall/am.mvn diff --git a/python/sensevoice/app/iic/SenseVoiceSmall/chn_jpn_yue_eng_ko_spectok.bpe.model b/plugins/model/stt-sensevoice/app/iic/SenseVoiceSmall/chn_jpn_yue_eng_ko_spectok.bpe.model similarity index 100% rename from python/sensevoice/app/iic/SenseVoiceSmall/chn_jpn_yue_eng_ko_spectok.bpe.model rename to plugins/model/stt-sensevoice/app/iic/SenseVoiceSmall/chn_jpn_yue_eng_ko_spectok.bpe.model diff --git a/python/sensevoice/app/iic/SenseVoiceSmall/config.yaml b/plugins/model/stt-sensevoice/app/iic/SenseVoiceSmall/config.yaml similarity index 100% rename from python/sensevoice/app/iic/SenseVoiceSmall/config.yaml rename to plugins/model/stt-sensevoice/app/iic/SenseVoiceSmall/config.yaml diff --git a/python/sensevoice/app/iic/SenseVoiceSmall/configuration.json b/plugins/model/stt-sensevoice/app/iic/SenseVoiceSmall/configuration.json similarity index 100% rename from python/sensevoice/app/iic/SenseVoiceSmall/configuration.json rename to plugins/model/stt-sensevoice/app/iic/SenseVoiceSmall/configuration.json diff --git a/python/sensevoice/app/iic/SenseVoiceSmall/fig/aed_figure.png b/plugins/model/stt-sensevoice/app/iic/SenseVoiceSmall/fig/aed_figure.png similarity index 100% rename from python/sensevoice/app/iic/SenseVoiceSmall/fig/aed_figure.png rename to plugins/model/stt-sensevoice/app/iic/SenseVoiceSmall/fig/aed_figure.png diff --git a/python/sensevoice/app/iic/SenseVoiceSmall/fig/asr_results.png b/plugins/model/stt-sensevoice/app/iic/SenseVoiceSmall/fig/asr_results.png similarity index 100% rename from python/sensevoice/app/iic/SenseVoiceSmall/fig/asr_results.png rename to plugins/model/stt-sensevoice/app/iic/SenseVoiceSmall/fig/asr_results.png diff --git a/python/sensevoice/app/iic/SenseVoiceSmall/fig/inference.png b/plugins/model/stt-sensevoice/app/iic/SenseVoiceSmall/fig/inference.png similarity index 100% rename from python/sensevoice/app/iic/SenseVoiceSmall/fig/inference.png rename to plugins/model/stt-sensevoice/app/iic/SenseVoiceSmall/fig/inference.png diff --git a/python/sensevoice/app/iic/SenseVoiceSmall/fig/sensevoice.png b/plugins/model/stt-sensevoice/app/iic/SenseVoiceSmall/fig/sensevoice.png similarity index 100% rename from python/sensevoice/app/iic/SenseVoiceSmall/fig/sensevoice.png rename to plugins/model/stt-sensevoice/app/iic/SenseVoiceSmall/fig/sensevoice.png diff --git a/python/sensevoice/app/iic/SenseVoiceSmall/fig/ser_figure.png b/plugins/model/stt-sensevoice/app/iic/SenseVoiceSmall/fig/ser_figure.png similarity index 100% rename from python/sensevoice/app/iic/SenseVoiceSmall/fig/ser_figure.png rename to plugins/model/stt-sensevoice/app/iic/SenseVoiceSmall/fig/ser_figure.png diff --git a/python/sensevoice/app/iic/SenseVoiceSmall/fig/ser_table.png b/plugins/model/stt-sensevoice/app/iic/SenseVoiceSmall/fig/ser_table.png similarity index 100% rename from python/sensevoice/app/iic/SenseVoiceSmall/fig/ser_table.png rename to plugins/model/stt-sensevoice/app/iic/SenseVoiceSmall/fig/ser_table.png diff --git a/python/sensevoice/app/iic/speech_fsmn_vad_zh-cn-16k-common-pytorch/.mdl b/plugins/model/stt-sensevoice/app/iic/speech_fsmn_vad_zh-cn-16k-common-pytorch/.mdl similarity index 100% rename from python/sensevoice/app/iic/speech_fsmn_vad_zh-cn-16k-common-pytorch/.mdl rename to plugins/model/stt-sensevoice/app/iic/speech_fsmn_vad_zh-cn-16k-common-pytorch/.mdl diff --git a/python/sensevoice/app/iic/speech_fsmn_vad_zh-cn-16k-common-pytorch/.msc b/plugins/model/stt-sensevoice/app/iic/speech_fsmn_vad_zh-cn-16k-common-pytorch/.msc similarity index 100% rename from python/sensevoice/app/iic/speech_fsmn_vad_zh-cn-16k-common-pytorch/.msc rename to plugins/model/stt-sensevoice/app/iic/speech_fsmn_vad_zh-cn-16k-common-pytorch/.msc diff --git a/python/sensevoice/app/iic/speech_fsmn_vad_zh-cn-16k-common-pytorch/.mv b/plugins/model/stt-sensevoice/app/iic/speech_fsmn_vad_zh-cn-16k-common-pytorch/.mv similarity index 100% rename from python/sensevoice/app/iic/speech_fsmn_vad_zh-cn-16k-common-pytorch/.mv rename to plugins/model/stt-sensevoice/app/iic/speech_fsmn_vad_zh-cn-16k-common-pytorch/.mv diff --git a/python/sensevoice/app/iic/speech_fsmn_vad_zh-cn-16k-common-pytorch/README.md b/plugins/model/stt-sensevoice/app/iic/speech_fsmn_vad_zh-cn-16k-common-pytorch/README.md similarity index 100% rename from python/sensevoice/app/iic/speech_fsmn_vad_zh-cn-16k-common-pytorch/README.md rename to plugins/model/stt-sensevoice/app/iic/speech_fsmn_vad_zh-cn-16k-common-pytorch/README.md diff --git a/python/sensevoice/app/iic/speech_fsmn_vad_zh-cn-16k-common-pytorch/am.mvn b/plugins/model/stt-sensevoice/app/iic/speech_fsmn_vad_zh-cn-16k-common-pytorch/am.mvn similarity index 100% rename from python/sensevoice/app/iic/speech_fsmn_vad_zh-cn-16k-common-pytorch/am.mvn rename to plugins/model/stt-sensevoice/app/iic/speech_fsmn_vad_zh-cn-16k-common-pytorch/am.mvn diff --git a/python/sensevoice/app/iic/speech_fsmn_vad_zh-cn-16k-common-pytorch/config.yaml b/plugins/model/stt-sensevoice/app/iic/speech_fsmn_vad_zh-cn-16k-common-pytorch/config.yaml similarity index 100% rename from python/sensevoice/app/iic/speech_fsmn_vad_zh-cn-16k-common-pytorch/config.yaml rename to plugins/model/stt-sensevoice/app/iic/speech_fsmn_vad_zh-cn-16k-common-pytorch/config.yaml diff --git a/python/sensevoice/app/iic/speech_fsmn_vad_zh-cn-16k-common-pytorch/configuration.json b/plugins/model/stt-sensevoice/app/iic/speech_fsmn_vad_zh-cn-16k-common-pytorch/configuration.json similarity index 100% rename from python/sensevoice/app/iic/speech_fsmn_vad_zh-cn-16k-common-pytorch/configuration.json rename to plugins/model/stt-sensevoice/app/iic/speech_fsmn_vad_zh-cn-16k-common-pytorch/configuration.json diff --git a/python/sensevoice/app/iic/speech_fsmn_vad_zh-cn-16k-common-pytorch/example/vad_example.wav b/plugins/model/stt-sensevoice/app/iic/speech_fsmn_vad_zh-cn-16k-common-pytorch/example/vad_example.wav similarity index 100% rename from python/sensevoice/app/iic/speech_fsmn_vad_zh-cn-16k-common-pytorch/example/vad_example.wav rename to plugins/model/stt-sensevoice/app/iic/speech_fsmn_vad_zh-cn-16k-common-pytorch/example/vad_example.wav diff --git a/python/sensevoice/app/iic/speech_fsmn_vad_zh-cn-16k-common-pytorch/fig/struct.png b/plugins/model/stt-sensevoice/app/iic/speech_fsmn_vad_zh-cn-16k-common-pytorch/fig/struct.png similarity index 100% rename from python/sensevoice/app/iic/speech_fsmn_vad_zh-cn-16k-common-pytorch/fig/struct.png rename to plugins/model/stt-sensevoice/app/iic/speech_fsmn_vad_zh-cn-16k-common-pytorch/fig/struct.png diff --git a/python/sensevoice/app/iic/speech_fsmn_vad_zh-cn-16k-common-pytorch/model.pt b/plugins/model/stt-sensevoice/app/iic/speech_fsmn_vad_zh-cn-16k-common-pytorch/model.pt similarity index 100% rename from python/sensevoice/app/iic/speech_fsmn_vad_zh-cn-16k-common-pytorch/model.pt rename to plugins/model/stt-sensevoice/app/iic/speech_fsmn_vad_zh-cn-16k-common-pytorch/model.pt diff --git a/python/sensevoice/app/main.py b/plugins/model/stt-sensevoice/app/main.py similarity index 100% rename from python/sensevoice/app/main.py rename to plugins/model/stt-sensevoice/app/main.py diff --git a/python/sensevoice/app/model.py b/plugins/model/stt-sensevoice/app/model.py similarity index 100% rename from python/sensevoice/app/model.py rename to plugins/model/stt-sensevoice/app/model.py diff --git a/python/sensevoice/app/requirements.txt b/plugins/model/stt-sensevoice/app/requirements.txt similarity index 100% rename from python/sensevoice/app/requirements.txt rename to plugins/model/stt-sensevoice/app/requirements.txt diff --git a/python/sensevoice/main.py b/plugins/model/stt-sensevoice/main.py similarity index 100% rename from python/sensevoice/main.py rename to plugins/model/stt-sensevoice/main.py diff --git a/python/sensevoice/run.sh b/plugins/model/stt-sensevoice/run.sh similarity index 100% rename from python/sensevoice/run.sh rename to plugins/model/stt-sensevoice/run.sh diff --git a/python/cosevoice/Dockerfile b/plugins/model/tts-cosevoice/Dockerfile similarity index 100% rename from python/cosevoice/Dockerfile rename to plugins/model/tts-cosevoice/Dockerfile diff --git a/python/cosevoice/fastapi/client.py b/plugins/model/tts-cosevoice/fastapi/client.py similarity index 100% rename from python/cosevoice/fastapi/client.py rename to plugins/model/tts-cosevoice/fastapi/client.py diff --git a/python/cosevoice/fastapi/server.py b/plugins/model/tts-cosevoice/fastapi/server.py similarity index 100% rename from python/cosevoice/fastapi/server.py rename to plugins/model/tts-cosevoice/fastapi/server.py diff --git a/python/cosevoice/grpc/client.py b/plugins/model/tts-cosevoice/grpc/client.py similarity index 100% rename from python/cosevoice/grpc/client.py rename to plugins/model/tts-cosevoice/grpc/client.py diff --git a/python/cosevoice/grpc/cosyvoice.proto b/plugins/model/tts-cosevoice/grpc/cosyvoice.proto similarity index 100% rename from python/cosevoice/grpc/cosyvoice.proto rename to plugins/model/tts-cosevoice/grpc/cosyvoice.proto diff --git a/python/cosevoice/grpc/server.py b/plugins/model/tts-cosevoice/grpc/server.py similarity index 100% rename from python/cosevoice/grpc/server.py rename to plugins/model/tts-cosevoice/grpc/server.py diff --git a/python/cosevoice/requirements.txt b/plugins/model/tts-cosevoice/requirements.txt similarity index 100% rename from python/cosevoice/requirements.txt rename to plugins/model/tts-cosevoice/requirements.txt diff --git a/projects/README.md b/projects/README.md new file mode 100644 index 000000000..f98add7a9 --- /dev/null +++ b/projects/README.md @@ -0,0 +1,6 @@ +# 目录说明 + +该目录为 FastGPT 主项目。 + +- app 前端项目,用于展示和使用 FastGPT。 +- sandbox 沙盒项目,用于测试和开发。 diff --git a/python/README.md b/python/README.md deleted file mode 100644 index d4ceed52c..000000000 --- a/python/README.md +++ /dev/null @@ -1,3 +0,0 @@ -# 目录说明 - -该目录为 python 辅助代码,非主项目代码,仅供学习使用,未参与实际生产。 diff --git a/python/api/README.md b/python/api/README.md deleted file mode 100644 index 0c1e0434e..000000000 --- a/python/api/README.md +++ /dev/null @@ -1,54 +0,0 @@ -# FastGPT-python-API -作者:stakeswky。有问题请这样联系我:stakeswky@gmail.com -## 1. 项目简介 -该API以python为技术栈,为fastgpt提供了一个简单易用的接口,方便fastgpt处理各种任务。该API的主要功能包括: -1. Word & PDF 图文提取 -在现有的文件读取中,fastgpt只能读取文件中的文字,而无法读取图片。该API可以将word和pdf中的文字和图片提取出来,方便fastgpt进行处理。 - -2. 网页递归获取 -该API可以递归获取指定页面的内容和挖掘该页面存在的链接指向页面的内容,请注意,该功能现在仅支持获取静态页面的内容,如果出现动态页面,可能会出现无法获取的情况。 - -3. (研发中。。) - -## 2. 安装方法 -### 必要的知识 -会使用Google -python的基本用法 -docker的基本用法 -百度OCR-API的文档:https://ai.baidu.com/ai-doc/OCR/Ek3h7xypm - -### 2.1 源码安装 -该API依赖于python3.8,请确保您的python版本符合要求。 -```shell -pip install -r requirements.txt -``` -引入环境变量:APP_ID,API_KEY,SECRET_KEY - -然后运行: -```shell -python main.py -``` -启动! - -### 2.2 Docker安装 -一把梭拉现成的镜像,直接拉下来用就行了。 -```shell -docker pull registry.cn-hangzhou.aliyuncs.com/fastgpt_docker/fastgpt_python_api:1.0 -``` -然后运行,三个环境变量记得配置成自己的: -```shell -docker run -d -p 6010:6010 -e APP_ID= -e API_KEY= -e SECRET_KEY= registry.cn-hangzhou.aliyuncs.com/fastgpt_docker/fastgpt_python_api:1.0 -``` - -或者你也可以自己打镜像 -```shell -docker build -t fastgpt-python-api . -``` -然后运行: -```shell -docker run -d -p 6010:6010 -e APP_ID= -e API_KEY= -e SECRET_KEY= fastgpt-python-api -``` -## 3. 使用方法 -目录下附带了两个测试案例,分别是word和pdf的图文提取,和网页递归获取。按照那个来使用就好 - - diff --git a/python/api/api.py b/python/api/api.py deleted file mode 100644 index f9aad4eca..000000000 --- a/python/api/api.py +++ /dev/null @@ -1,74 +0,0 @@ -import os -from fastapi import FastAPI, File, UploadFile -from fastapi.responses import JSONResponse -from pydantic import BaseModel -from services.office2txt import office_to_txt -from typing import List -from fastapi import HTTPException -from services.fetch import get_summary -import aiofiles -import queue -import uuid - - -# 请求模型 -class SummaryRequest(BaseModel): - url: str - level: int - -# 响应模型 -class SummaryResponse(BaseModel): - url: str - title: str - summary: str - -class ExtractedText(BaseModel): - text: str - - -# 文件转文本 -async def process_file(file: UploadFile): - file_ext = os.path.splitext(file.filename)[1].lower() - if file_ext not in ['.docx', '.pdf', '.doc', '.txt']: - return JSONResponse(content={"error": "Unsupported file format"}, status_code=400) - - # 生成唯一的文件名 - unique_filename = f"{uuid.uuid4()}{file_ext}" - - try: - # 读取文件内容并保存到唯一命名的文件中 - async with aiofiles.open(unique_filename, "wb") as out_file: - while True: - contents = await file.read(1024) # 以块的方式读取文件 - if not contents: - break - await out_file.write(contents) - - # 文件处理逻辑,注意传入新的唯一文件名 - extracted_text = office_to_txt(unique_filename) - print(extracted_text) - return {"text": extracted_text} - except Exception as e: - return JSONResponse(content={"error": str(e)}, status_code=500) - finally: - # 清理:删除临时保存的唯一命名文件 - if os.path.exists(unique_filename): - os.remove(unique_filename) - - - -# 定义一个处理网页摘要的函数 -async def process_summary(request): - if request.level < 0: - raise HTTPException(status_code=400, detail="Level must be non-negative.") - try: - # 使用定义的函数来获取网页摘要 - summaries = get_summary(request.url, request.level) - # 将结果转换为响应模型列表 - print(summaries) - return [SummaryResponse(url=url, title=title, summary=summary) for url, title, summary in summaries] - except Exception as e: - raise HTTPException(status_code=500, detail=str(e)) - - - diff --git a/python/api/dockerfile b/python/api/dockerfile deleted file mode 100644 index 8d6fa54fb..000000000 --- a/python/api/dockerfile +++ /dev/null @@ -1,20 +0,0 @@ -# 使用官方Python运行时作为父镜像 -FROM python:3.8 - -# 设置工作目录 -WORKDIR /app - -# 将当前目录内容复制到容器的/app中 -ADD . /app - -RUN pip install --upgrade -i https://pypi.tuna.tsinghua.edu.cn/simple pip -# 安装程序需要的包 -RUN pip install -i https://pypi.tuna.tsinghua.edu.cn/simple --no-cache-dir -r requirements.txt - -RUN python -m nltk.downloader punkt - -# 运行时监听的端口 -EXPOSE 6010 - -# 运行app.py时的命令及其参数 -CMD ["python", "main.py"] diff --git a/python/api/main.py b/python/api/main.py deleted file mode 100644 index bd6133431..000000000 --- a/python/api/main.py +++ /dev/null @@ -1,48 +0,0 @@ -from fastapi.middleware.cors import CORSMiddleware -from fastapi import FastAPI, File, UploadFile -import queue -from typing import List -from api import SummaryRequest, SummaryResponse, ExtractedText,process_file,process_summary -import uvicorn - -app = FastAPI() - -app.add_middleware( - CORSMiddleware, - allow_origins=["*"], - allow_credentials=True, - allow_methods=["*"], - allow_headers=["*"], -) - - -q = queue.Queue() - -# 定义一个接口,接收文件并将其放入队列中 -@app.post("/extract_text/", response_model=ExtractedText) -async def extract_text(file: UploadFile = File(...)): - # 将文件对象放入队列中,先进先出 - q.put(file) - # 从队列中取出文件对象,并调用处理函数 - file = q.get() - result = await process_file(file) - # 标记队列中的任务已完成 - q.task_done() - # 返回处理结果 - return result - -# 定义一个接口,接收请求并将其放入队列中 -@app.post("/generate_summary/", response_model=List[SummaryResponse]) -async def generate_summary(request: SummaryRequest): - # 将请求对象放入队列中,先进先出 - q.put(request) - # 从队列中取出请求对象,并调用处理函数 - request = q.get() - result = await process_summary(request) - # 标记队列中的任务已完成 - q.task_done() - # 返回处理结果 - return result - -if __name__ == "__main__": - uvicorn.run(app, host="0.0.0.0", port=6010) \ No newline at end of file diff --git a/python/api/requirements.txt b/python/api/requirements.txt deleted file mode 100644 index 0b7a34f06..000000000 --- a/python/api/requirements.txt +++ /dev/null @@ -1,14 +0,0 @@ -aiofiles==23.2.1 -baidu_aip==4.16.12 -beautifulsoup4==4.11.1 -fastapi==0.104.1 -nltk==3.8.1 -pdf2image==1.16.3 -pydantic==1.10.7 -PyPDF2==3.0.1 -python_docx==0.8.11 -python_pptx==0.6.21 -Requests==2.31.0 -uvicorn==0.24.0 -chardet==5.2.0 -python-multipart==0.0.6 \ No newline at end of file diff --git a/python/api/services/fetch.py b/python/api/services/fetch.py deleted file mode 100644 index 92df68d77..000000000 --- a/python/api/services/fetch.py +++ /dev/null @@ -1,90 +0,0 @@ -import requests -import bs4 -import nltk -from urllib.parse import urljoin -from time import sleep -import time -import math - -# 全局变量来记录开始时间 -start_time = time.time() - -# 你可以设定一个最大运行时长,比如60秒 -max_run_time = 20 - -# 添加一个简单的IDF计算器 -class SimpleIDFCalculator: - def __init__(self): - self.doc_freq = {} - self.num_docs = 0 - - def add_document(self, doc): - self.num_docs += 1 - words = set(nltk.word_tokenize(doc)) - for word in words: - if word in self.doc_freq: - self.doc_freq[word] += 1 - else: - self.doc_freq[word] = 1 - - def idf(self, word): - return math.log(self.num_docs / (1 + self.doc_freq.get(word, 0))) - - - -# 定义一个函数,用于获取网页的内容,并进行总结 -def get_summary(url, level): - result = [] - visited = set() - idf_calculator = SimpleIDFCalculator() - helper(url, level, result, visited, idf_calculator) - return result - -# 辅助函数 -def helper(url, level, result, visited, idf_calculator): - # # 检查是否超出运行时间限制 - # if time.time() - start_time > max_run_time: - # print("Reached max run time, exiting...") - # return - - if level == 0 or url in visited or not url.startswith("http"): - return - - visited.add(url) - try: - response = requests.get(url) - if response.status_code != 200: - return - soup = bs4.BeautifulSoup(response.text, "html.parser") - title = soup.title.string if soup.title else 'No Title' - text = soup.get_text().strip() - idf_calculator.add_document(text) - sentences = nltk.sent_tokenize(text) - words = nltk.word_tokenize(text) - - scores = {} - for sentence in sentences: - for word in nltk.word_tokenize(sentence): - tf = words.count(word) / len(words) - idf = idf_calculator.idf(word) - scores[sentence] = scores.get(sentence, 0) + (tf * idf) - - summary = " ".join(sorted(scores, key=scores.get, reverse=True)[:10]) - result.append((url, title, summary)) - - sleep(1) # Simple delay to prevent aggressive crawling - - links = soup.find_all("a") - for link in links: - href = link.get("href") - if href: - # Handle relative links - next_url = urljoin(url, href) - helper(next_url, level - 1, result, visited, idf_calculator) - - except Exception as e: - print(f"Error processing {url}: {e}") - -# # 主程序部分,仅作为函数调用示例: -# summary = get_summary('https://zhihu.com', 2) -# print(summary) diff --git a/python/api/services/office2txt.py b/python/api/services/office2txt.py deleted file mode 100644 index 5d9b0ae7f..000000000 --- a/python/api/services/office2txt.py +++ /dev/null @@ -1,93 +0,0 @@ -import os -import docx -from aip import AipOcr -from io import BytesIO -from PyPDF2 import PdfReader -from pdf2image import convert_from_path - - -# 百度OCR API设置 -APP_ID = os.environ.get('APP_ID','xxx') -API_KEY = os.environ.get('API_KEY','xxx') -SECRET_KEY = os.environ.get('SECRET_KEY','xxx') - - - -client = AipOcr(APP_ID, API_KEY, SECRET_KEY) - -def ocr_image(image_data): - result = client.basicGeneral(image_data) - text = '' - if 'words_result' in result: - for item in result['words_result']: - text += item['words'] + '\n' - return text - -def process_pdf(file_path): - pdf = PdfReader(file_path) - num_pages = len(pdf.pages) - text = '' - for page_num in range(num_pages): - page = pdf.pages[page_num] - text += f'--------------------------------------------\n' - text += f'文档名:{os.path.basename(file_path)}\n' - text += f'页数:{page_num + 1}\n' - text += f'该页内容:\n' - text += page.extract_text() + '\n' - images = convert_from_path(file_path, first_page=page_num + 1, last_page=page_num + 1) - for image in images: - image_data = BytesIO() - image.save(image_data, format='PNG') - image_data = image_data.getvalue() - ocr_text = ocr_image(image_data) - if ocr_text: - text += f'图片文字:\n' - text += ocr_text + '\n' - text += '--------------------------------------------\n' - return text - -def process_doc(file_path): - doc = docx.Document(file_path) - text = '' - page_num = 1 - for paragraph in doc.paragraphs: - if paragraph.text.strip() == '': # 简单地将空行视为分页符 - page_num += 1 - else: - text += f'--------------------------------------------\n' - text += f'文档名:{os.path.basename(file_path)}\n' - text += f'页数:{page_num}\n' - text += f'该页内容:\n' - text += paragraph.text + '\n' - - for shape in doc.inline_shapes: - if shape.type == docx.enum.shape.WD_INLINE_SHAPE.PICTURE: - blip_id = shape._inline.graphic.graphicData.pic.blipFill.blip.embed - image_part = doc.part.related_parts[blip_id] - image_data = image_part.blob - ocr_text = ocr_image(image_data) - if ocr_text: - text += f'图片文字:\n' - text += ocr_text + '\n' - - return text - -def process_txt(file_path): - with open(file_path, 'r', encoding='utf-8') as f: - text = f.read() - return text - -def office_to_txt(file_path): - file_ext = os.path.splitext(file_path)[1].lower() - if file_ext == '.docx': - return process_doc(file_path) - elif file_ext == '.pdf': - return process_pdf(file_path) - elif file_ext == '.doc': - return process_doc(file_path) - elif file_ext == '.txt': - return process_txt(file_path) - - else: - raise ValueError('Unsupported file format') - diff --git a/python/api/test/fetch_test.py b/python/api/test/fetch_test.py deleted file mode 100644 index 86361b5e3..000000000 --- a/python/api/test/fetch_test.py +++ /dev/null @@ -1,25 +0,0 @@ -import requests - -# 接口的URL -api_url = "http://127.0.0.1:6010/generate_summary/" - -# 请求的数据 -data = { - "url": "https://bing.com", - "level": 1 -} - -# 发送POST请求 -response = requests.post(api_url, json=data) - -# 检查响应状态 -if response.status_code == 200: - # 请求成功,打印结果 - summaries = response.json() - for summary in summaries: - print(f"URL: {summary['url']}") - print(f"Title: {summary['title']}") - print(f"Summary: {summary['summary']}\n") -else: - # 请求失败,打印错误信息 - print(f"Failed to generate summary with status code {response.status_code}: {response.text}") diff --git a/python/api/test/office_test.py b/python/api/test/office_test.py deleted file mode 100644 index 1a7d67f15..000000000 --- a/python/api/test/office_test.py +++ /dev/null @@ -1,49 +0,0 @@ -import requests -import pytest -from docx import Document -import os -from tempfile import NamedTemporaryFile -from docx.shared import Inches - -image_path = os.path.join(os.path.dirname(__file__), "test.png") - -# 定义一个函数来创建一个新的Word文档,并添加一个图片 -def create_test_docx_with_image(): - # 使用临时文件来避免文件名冲突 - temp_file = NamedTemporaryFile(delete=False, suffix='.docx') - # 创建一个文档对象 - doc = Document() - # 添加一个段落 - doc.add_paragraph("This is a test document with an image.") - # 添加一个图片,确保提供的图片路径是有效的 - doc.add_picture(image_path, width=Inches(1.25)) # 图片宽度设为1.25英寸 - # 保存文档到临时文件 - doc.save(temp_file.name) - # 关闭临时文件 - temp_file.close() - # 返回文件路径 - return temp_file.name - -# 定义一个函数,它将创建并发送多个Word文档,并返回响应对象列表 -def get_responses(): - responses = [] - # 创建并发送10个文档 - for _ in range(10): - test_file_path = create_test_docx_with_image() - with open(test_file_path, "rb") as f: - files = {"file": (os.path.basename(test_file_path), f, "application/vnd.openxmlformats-officedocument.wordprocessingml.document")} - response = requests.post("http://127.0.0.1:6010/extract_text/", files=files) - responses.append(response) - # 测试完成后删除文件 - os.unlink(test_file_path) - return responses - -# 使用pytest的parametrize装饰器测试所有响应 -@pytest.mark.parametrize("response", get_responses()) -def test_response(response): - # 断言响应的状态码为200 - assert response.status_code == 200 - # 断言响应的内容类型是application/json - assert "application/json" in response.headers["Content-Type"] - # 断言响应的数据包含文本信息 - assert "text" in response.json()