该 API 允许用户上传和搜索不同场景中的文档。该 API 支持以下端点:
将文件上传到指定的场景和路径。
端点: POST /api/documents/{scene}/{path}
请求参数:
scene
(字符串):场景的名称。
path
(字符串):文件应存储在场景中的路径。
请求体:
file
(multipart/form-data):要上传的文件。
示例请求:
1curl -X POST -F "file=@/path/to/file.pdf" http://localhost:8000/api/documents/scene1/folder1
示例响应:
xxxxxxxxxx
31{
2 "message": "文件 file.pdf 已上传至 scene1/folder1"
3}
从指定的场景中删除文件。
端点: DELETE /api/documents/{scene}
请求参数:
scene
(字符串):场景的名称。
请求体:
file
(字符串):要删除的文件的名称。
示例请求:
xxxxxxxxxx
11curl -X DELETE -d "file=file.pdf" http://localhost:8000/api/documents/scene1
示例响应:
xxxxxxxxxx
31{
2 "message": "文件 file.pdf 已删除"
3}
列出指定场景中的所有文档。
端点: GET /api/documents/{scene}
请求参数:
scene
(字符串):场景的名称。
示例请求:
xxxxxxxxxx
11curl http://localhost:8000/api/documents/scene1
示例响应:
xxxxxxxxxx
11[{"source":"scenes/krsj4/docs/狂人手记.txt"},{"source":"scenes/krsj4/docs/狂人手记.txt"}
根据查询条件搜索指定场景中的文档。
端点: GET /api/{scene}/search
请求参数:
scene
(字符串):场景的名称。
q
(字符串):搜索查询条件。
示例请求:
xxxxxxxxxx
11curl http://localhost:8000/api/scene1/search?q=关键词
示例响应:
xxxxxxxxxx
121[
2 {
3 "page_content": "Lorem ipsum dolor sit amet...",
4 "source": "file1.pdf",
5 "score": 0.85
6 },
7 {
8 "page_content": "Consectetur adipiscing elit...",
9 "source": "file2.docx",
10 "score": 0.72
11 }
12]
请注意,您需要将 http://localhost:8000
替换为实际 API 服务器的 URL。