update code positon (#3907)
@@ -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. 安装依赖
|
||||
|
||||
|
@@ -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 安装的方法:
|
||||
|
||||
|
@@ -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. 修改环境变量
|
||||
|
@@ -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`
|
||||
|
@@ -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 输出调试。
|
||||
|
3
packages/README.md
Normal file
@@ -0,0 +1,3 @@
|
||||
# 目录说明
|
||||
|
||||
该目录为 FastGPT 的依赖包,多端复用。
|
5
plugins/README.md
Normal file
@@ -0,0 +1,5 @@
|
||||
# 目录说明
|
||||
|
||||
该目录为 FastGPT 辅助子项目,非必须。
|
||||
|
||||
- model 私有化模型
|
Before Width: | Height: | Size: 91 KiB After Width: | Height: | Size: 91 KiB |
Before Width: | Height: | Size: 86 KiB After Width: | Height: | Size: 86 KiB |
Before Width: | Height: | Size: 77 KiB After Width: | Height: | Size: 77 KiB |
Before Width: | Height: | Size: 293 KiB After Width: | Height: | Size: 293 KiB |
Before Width: | Height: | Size: 332 KiB After Width: | Height: | Size: 332 KiB |
Before Width: | Height: | Size: 167 KiB After Width: | Height: | Size: 167 KiB |
Before Width: | Height: | Size: 146 KiB After Width: | Height: | Size: 146 KiB |
Before Width: | Height: | Size: 18 KiB After Width: | Height: | Size: 18 KiB |
6
projects/README.md
Normal file
@@ -0,0 +1,6 @@
|
||||
# 目录说明
|
||||
|
||||
该目录为 FastGPT 主项目。
|
||||
|
||||
- app 前端项目,用于展示和使用 FastGPT。
|
||||
- sandbox 沙盒项目,用于测试和开发。
|
@@ -1,3 +0,0 @@
|
||||
# 目录说明
|
||||
|
||||
该目录为 python 辅助代码,非主项目代码,仅供学习使用,未参与实际生产。
|
@@ -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=<your_app_id> -e API_KEY=<your_api_key> -e SECRET_KEY=<your_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=<your_app_id> -e API_KEY=<your_api_key> -e SECRET_KEY=<your_secret_key> fastgpt-python-api
|
||||
```
|
||||
## 3. 使用方法
|
||||
目录下附带了两个测试案例,分别是word和pdf的图文提取,和网页递归获取。按照那个来使用就好
|
||||
|
||||
|
@@ -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))
|
||||
|
||||
|
||||
|