diff --git a/docs/API.md b/docs/API.md
index 8895af422..f116d2a62 100644
--- a/docs/API.md
+++ b/docs/API.md
@@ -46,22 +46,7 @@ X-Request-ID: unique_request_id
获取 API Key 有以下方式:
-1. **创建租户时获取**:通过 `POST /api/v1/tenants` 接口创建新租户时,响应中会自动返回生成的 API Key。
- ```json
- {
- "success": true,
- "data": {
- "id": 1,
- "name": "租户名称",
- "description": "租户描述",
- "api_key": "生成的API密钥",
- "created_at": "2023-01-01T00:00:00Z",
- "updated_at": "2023-01-01T00:00:00Z"
- }
- }
- ```
-
-2. **查看现有租户信息**:通过 `GET /api/v1/tenants/:id` 接口查看已有租户的详细信息,响应中包含 API Key。
+**创建租户时获取**:通过 `POST /api/v1/tenants` 接口创建新租户时,响应中会自动返回生成的 API Key。
请妥善保管您的 API Key,避免泄露。API Key 代表您的账户身份,拥有完整的 API 访问权限。
@@ -112,6 +97,60 @@ WeKnora API 按功能分为以下几类:
**请求体**:
+```curl
+curl --location 'http://localhost:8080/api/v1/tenants' \
+--header 'Content-Type: application/json' \
+--data '{
+ "name": "weknora",
+ "description": "weknora tenants",
+ "business": "wechat",
+ "retriever_engines": {
+ "engines": [
+ {
+ "retriever_type": "keywords",
+ "retriever_engine_type": "postgres"
+ },
+ {
+ "retriever_type": "vector",
+ "retriever_engine_type": "postgres"
+ }
+ ]
+ }
+}'
+```
+
+**响应**:
+
+```json
+{
+ "data": {
+ "id": 10000,
+ "name": "weknora",
+ "description": "weknora tenants",
+ "api_key": "sk-aaLRAgvCRJcmtiL2vLMeB1FB5UV0Q-qB7DlTE1pJ9KA93XZG",
+ "status": "active",
+ "retriever_engines": {
+ "engines": [
+ {
+ "retriever_engine_type": "postgres",
+ "retriever_type": "keywords"
+ },
+ {
+ "retriever_engine_type": "postgres",
+ "retriever_type": "vector"
+ }
+ ]
+ },
+ "business": "wechat",
+ "storage_quota": 10737418240,
+ "storage_used": 0,
+ "created_at": "2025-08-11T20:37:28.396980093+08:00",
+ "updated_at": "2025-08-11T20:37:28.396980301+08:00",
+ "deleted_at": null
+ },
+ "success": true
+}
+```
```json
{
"name": "租户名称",
@@ -119,105 +158,178 @@ WeKnora API 按功能分为以下几类:
}
```
-**响应**:
-
-```json
-{
- "success": true,
- "data": {
- "id": 1,
- "name": "租户名称",
- "description": "租户描述",
- "api_key": "生成的API密钥",
- "created_at": "2023-01-01T00:00:00Z",
- "updated_at": "2023-01-01T00:00:00Z"
- }
-}
-```
-
#### GET `/tenants/:id` - 获取指定租户信息
-**响应**:
-
-```json
-{
- "success": true,
- "data": {
- "id": 1,
- "name": "租户名称",
- "description": "租户描述",
- "api_key": "API密钥",
- "created_at": "2023-01-01T00:00:00Z",
- "updated_at": "2023-01-01T00:00:00Z"
- }
-}
-```
-
-#### PUT `/tenants/:id` - 更新租户信息
-
**请求体**:
-```json
-{
- "name": "新租户名称",
- "description": "新租户描述"
-}
+```curl
+curl --location 'http://localhost:8080/api/v1/tenants/10000' \
+--header 'Content-Type: application/json' \
+--header 'X-API-Key: sk-aaLRAgvCRJcmtiL2vLMeB1FB5UV0Q-qB7DlTE1pJ9KA93XZG'
```
**响应**:
```json
{
- "success": true,
- "data": {
- "id": 1,
- "name": "新租户名称",
- "description": "新租户描述",
- "api_key": "API密钥",
- "created_at": "2023-01-01T00:00:00Z",
- "updated_at": "2023-01-01T00:00:00Z"
- }
+ "data": {
+ "id": 10000,
+ "name": "weknora",
+ "description": "weknora tenants",
+ "api_key": "sk-aaLRAgvCRJcmtiL2vLMeB1FB5UV0Q-qB7DlTE1pJ9KA93XZG",
+ "status": "active",
+ "retriever_engines": {
+ "engines": [
+ {
+ "retriever_engine_type": "postgres",
+ "retriever_type": "keywords"
+ },
+ {
+ "retriever_engine_type": "postgres",
+ "retriever_type": "vector"
+ }
+ ]
+ },
+ "business": "wechat",
+ "storage_quota": 10737418240,
+ "storage_used": 0,
+ "created_at": "2025-08-11T20:37:28.39698+08:00",
+ "updated_at": "2025-08-11T20:37:28.405693+08:00",
+ "deleted_at": null
+ },
+ "success": true
+}
+```
+
+**响应**:
+
+#### PUT `/tenants/:id` - 更新租户信息
+
+注意 API Key 会变更
+
+**请求体**:
+
+```curl
+curl --location --request PUT 'http://localhost:8080/api/v1/tenants/10000' \
+--header 'Content-Type: application/json' \
+--header 'X-API-Key: sk-KREi84yPtahKxMtIMOW-Cxx2dxb9xROpUuDSpi3vbiC1QVDe' \
+--data '{
+ "name": "weknora new",
+ "description": "weknora tenants new",
+ "status": "active",
+ "retriever_engines": {
+ "engines": [
+ {
+ "retriever_engine_type": "postgres",
+ "retriever_type": "keywords"
+ },
+ {
+ "retriever_engine_type": "postgres",
+ "retriever_type": "vector"
+ }
+ ]
+ },
+ "business": "wechat",
+ "storage_quota": 10737418240
+}'
+```
+
+**响应**:
+
+```json
+{
+ "data": {
+ "id": 10000,
+ "name": "weknora new",
+ "description": "weknora tenants new",
+ "api_key": "sk-IKtd9JGV4-aPGQ6RiL8YJu9Vzb3-ae4lgFkjFJZmhvUn2mLu",
+ "status": "active",
+ "retriever_engines": {
+ "engines": [
+ {
+ "retriever_engine_type": "postgres",
+ "retriever_type": "keywords"
+ },
+ {
+ "retriever_engine_type": "postgres",
+ "retriever_type": "vector"
+ }
+ ]
+ },
+ "business": "wechat",
+ "storage_quota": 10737418240,
+ "storage_used": 0,
+ "created_at": "0001-01-01T00:00:00Z",
+ "updated_at": "2025-08-11T20:49:02.13421034+08:00",
+ "deleted_at": null
+ },
+ "success": true
}
```
#### DELETE `/tenants/:id` - 删除租户
+**请求**:
+
+```curl
+curl --location --request DELETE 'http://localhost:8080/api/v1/tenants/10000' \
+--header 'Content-Type: application/json' \
+--header 'X-API-Key: sk-IKtd9JGV4-aPGQ6RiL8YJu9Vzb3-ae4lgFkjFJZmhvUn2mLu'
+```
+
**响应**:
```json
{
- "success": true,
- "message": "租户删除成功"
+ "message": "Tenant deleted successfully",
+ "success": true
}
```
#### GET `/tenants` - 获取租户列表
+**请求**:
+
+```curl
+curl --location 'http://localhost:8080/api/v1/tenants' \
+--header 'Content-Type: application/json' \
+--header 'X-API-Key: sk-An7_t_izCKFIJ4iht9Xjcjnj_MC48ILvwezEDki9ScfIa7KA'
+```
+
**响应**:
```json
{
- "success": true,
- "data": {
- "items": [
- {
- "id": 1,
- "name": "租户1",
- "description": "租户1描述",
- "api_key": "API密钥1",
- "created_at": "2023-01-01T00:00:00Z",
- "updated_at": "2023-01-01T00:00:00Z"
- },
- {
- "id": 2,
- "name": "租户2",
- "description": "租户2描述",
- "api_key": "API密钥2",
- "created_at": "2023-01-01T00:00:00Z",
- "updated_at": "2023-01-01T00:00:00Z"
- }
- ]
- }
+ "data": {
+ "items": [
+ {
+ "id": 10002,
+ "name": "weknora",
+ "description": "weknora tenants",
+ "api_key": "sk-An7_t_izCKFIJ4iht9Xjcjnj_MC48ILvwezEDki9ScfIa7KA",
+ "status": "active",
+ "retriever_engines": {
+ "engines": [
+ {
+ "retriever_engine_type": "postgres",
+ "retriever_type": "keywords"
+ },
+ {
+ "retriever_engine_type": "postgres",
+ "retriever_type": "vector"
+ }
+ ]
+ },
+ "business": "wechat",
+ "storage_quota": 10737418240,
+ "storage_used": 0,
+ "created_at": "2025-08-11T20:52:58.05679+08:00",
+ "updated_at": "2025-08-11T20:52:58.060495+08:00",
+ "deleted_at": null
+ }
+ ]
+ },
+ "success": true
}
```
@@ -239,97 +351,214 @@ WeKnora API 按功能分为以下几类:
**请求体**:
-```json
-{
- "name": "知识库名称",
- "description": "知识库描述",
- "config": {
- "chunk_size": 1000,
- "chunk_overlap": 200
- },
- "embedding_model_id": "模型ID"
-}
+```curl
+curl --location 'http://localhost:8080/api/v1/knowledge-bases' \
+--header 'Content-Type: application/json' \
+--header 'X-API-Key: sk-vQHV2NZI_LK5W7wHQvH3yGYExX8YnhaHwZipUYbiZKCYJbBQ' \
+--data '{
+ "name": "weknora",
+ "description": "weknora description",
+ "chunking_config": {
+ "chunk_size": 1000,
+ "chunk_overlap": 200,
+ "separators": [
+ "."
+ ],
+ "enable_multimodal": true
+ },
+ "image_processing_config": {
+ "model_id": "f2083ad7-63e3-486d-a610-e6c56e58d72e"
+ },
+ "embedding_model_id": "dff7bc94-7885-4dd1-bfd5-bd96e4df2fc3",
+ "summary_model_id": "8aea788c-bb30-4898-809e-e40c14ffb48c",
+ "rerank_model_id": "b30171a1-787b-426e-a293-735cd5ac16c0",
+ "vlm_model_id": "f2083ad7-63e3-486d-a610-e6c56e58d72e",
+ "vlm_config": {
+ "model_name": "qwen2.5vl:3b",
+ "interface_type": "ollama",
+ "base_url": "",
+ "api_key": ""
+ },
+ "cos_config": {
+ "secret_id": "",
+ "secret_key": "",
+ "region": "",
+ "bucket_name": "",
+ "app_id": "",
+ "path_prefix": ""
+ }
+}'
```
**响应**:
```json
{
- "success": true,
- "data": {
- "id": "知识库ID",
- "tenant_id": 1,
- "name": "知识库名称",
- "description": "知识库描述",
- "config": {
- "chunk_size": 1000,
- "chunk_overlap": 200
+ "data": {
+ "id": "b5829e4a-3845-4624-a7fb-ea3b35e843b0",
+ "name": "weknora",
+ "description": "weknora description",
+ "tenant_id": 1,
+ "chunking_config": {
+ "chunk_size": 1000,
+ "chunk_overlap": 200,
+ "separators": [
+ "."
+ ],
+ "enable_multimodal": true
+ },
+ "image_processing_config": {
+ "model_id": "f2083ad7-63e3-486d-a610-e6c56e58d72e"
+ },
+ "embedding_model_id": "dff7bc94-7885-4dd1-bfd5-bd96e4df2fc3",
+ "summary_model_id": "8aea788c-bb30-4898-809e-e40c14ffb48c",
+ "rerank_model_id": "b30171a1-787b-426e-a293-735cd5ac16c0",
+ "vlm_model_id": "f2083ad7-63e3-486d-a610-e6c56e58d72e",
+ "vlm_config": {
+ "model_name": "qwen2.5vl:3b",
+ "base_url": "",
+ "api_key": "",
+ "interface_type": "ollama"
+ },
+ "cos_config": {
+ "secret_id": "",
+ "secret_key": "",
+ "region": "",
+ "bucket_name": "",
+ "app_id": "",
+ "path_prefix": ""
+ },
+ "created_at": "2025-08-12T11:30:09.206238645+08:00",
+ "updated_at": "2025-08-12T11:30:09.206238854+08:00",
+ "deleted_at": null
},
- "embedding_model_id": "模型ID",
- "created_at": "2023-01-01T00:00:00Z",
- "updated_at": "2023-01-01T00:00:00Z"
- }
+ "success": true
}
```
#### GET `/knowledge-bases` - 获取知识库列表
+**请求**:
+
+```curl
+curl --location 'http://localhost:8080/api/v1/knowledge-bases' \
+--header 'Content-Type: application/json' \
+--header 'X-API-Key: sk-vQHV2NZI_LK5W7wHQvH3yGYExX8YnhaHwZipUYbiZKCYJbBQ'
+```
+
**响应**:
```json
{
- "success": true,
- "data": [
- {
- "id": "知识库ID1",
- "tenant_id": 1,
- "name": "知识库1",
- "description": "知识库1描述",
- "config": {
- "chunk_size": 1000,
- "chunk_overlap": 200
- },
- "embedding_model_id": "模型ID",
- "created_at": "2023-01-01T00:00:00Z",
- "updated_at": "2023-01-01T00:00:00Z"
- },
- {
- "id": "知识库ID2",
- "tenant_id": 1,
- "name": "知识库2",
- "description": "知识库2描述",
- "config": {
- "chunk_size": 1000,
- "chunk_overlap": 200
- },
- "embedding_model_id": "模型ID",
- "created_at": "2023-01-01T00:00:00Z",
- "updated_at": "2023-01-01T00:00:00Z"
- }
- ]
+ "data": [
+ {
+ "id": "kb-00000001",
+ "name": "Default Knowledge Base",
+ "description": "System Default Knowledge Base",
+ "tenant_id": 1,
+ "chunking_config": {
+ "chunk_size": 1000,
+ "chunk_overlap": 200,
+ "separators": [
+ "\n\n",
+ "\n",
+ "。",
+ "!",
+ "?",
+ ";",
+ ";"
+ ],
+ "enable_multimodal": true
+ },
+ "image_processing_config": {
+ "model_id": ""
+ },
+ "embedding_model_id": "dff7bc94-7885-4dd1-bfd5-bd96e4df2fc3",
+ "summary_model_id": "8aea788c-bb30-4898-809e-e40c14ffb48c",
+ "rerank_model_id": "b30171a1-787b-426e-a293-735cd5ac16c0",
+ "vlm_model_id": "f2083ad7-63e3-486d-a610-e6c56e58d72e",
+ "vlm_config": {
+ "model_name": "qwen2.5vl:3b",
+ "base_url": "http://host.docker.internal:11435/v1",
+ "api_key": "",
+ "interface_type": "ollama"
+ },
+ "cos_config": {
+ "secret_id": "",
+ "secret_key": "",
+ "region": "",
+ "bucket_name": "",
+ "app_id": "",
+ "path_prefix": ""
+ },
+ "created_at": "2025-08-11T20:10:41.817794+08:00",
+ "updated_at": "2025-08-12T11:23:00.593097+08:00",
+ "deleted_at": null
+ }
+ ],
+ "success": true
}
```
#### GET `/knowledge-bases/:id` - 获取知识库详情
+**请求**:
+
+```curl
+curl --location 'http://localhost:8080/api/v1/knowledge-bases/kb-00000001' \
+--header 'Content-Type: application/json' \
+--header 'X-API-Key: sk-vQHV2NZI_LK5W7wHQvH3yGYExX8YnhaHwZipUYbiZKCYJbBQ'
+```
+
**响应**:
```json
{
- "success": true,
- "data": {
- "id": "知识库ID",
- "tenant_id": 1,
- "name": "知识库名称",
- "description": "知识库描述",
- "config": {
- "chunk_size": 1000,
- "chunk_overlap": 200
+ "data": {
+ "id": "kb-00000001",
+ "name": "Default Knowledge Base",
+ "description": "System Default Knowledge Base",
+ "tenant_id": 1,
+ "chunking_config": {
+ "chunk_size": 1000,
+ "chunk_overlap": 200,
+ "separators": [
+ "\n\n",
+ "\n",
+ "。",
+ "!",
+ "?",
+ ";",
+ ";"
+ ],
+ "enable_multimodal": true
+ },
+ "image_processing_config": {
+ "model_id": ""
+ },
+ "embedding_model_id": "dff7bc94-7885-4dd1-bfd5-bd96e4df2fc3",
+ "summary_model_id": "8aea788c-bb30-4898-809e-e40c14ffb48c",
+ "rerank_model_id": "b30171a1-787b-426e-a293-735cd5ac16c0",
+ "vlm_model_id": "f2083ad7-63e3-486d-a610-e6c56e58d72e",
+ "vlm_config": {
+ "model_name": "qwen2.5vl:3b",
+ "base_url": "http://host.docker.internal:11435/v1",
+ "api_key": "",
+ "interface_type": "ollama"
+ },
+ "cos_config": {
+ "secret_id": "",
+ "secret_key": "",
+ "region": "",
+ "bucket_name": "",
+ "app_id": "",
+ "path_prefix": ""
+ },
+ "created_at": "2025-08-11T20:10:41.817794+08:00",
+ "updated_at": "2025-08-12T11:23:00.593097+08:00",
+ "deleted_at": null
},
- "embedding_model_id": "模型ID",
- "created_at": "2023-01-01T00:00:00Z",
- "updated_at": "2023-01-01T00:00:00Z"
- }
+ "success": true
}
```
@@ -337,81 +566,148 @@ WeKnora API 按功能分为以下几类:
**请求体**:
-```json
-{
- "name": "新知识库名称",
- "description": "新知识库描述",
- "config": {
- "chunk_size": 800,
- "chunk_overlap": 150
- }
-}
+```curl
+curl --location --request PUT 'http://localhost:8080/api/v1/knowledge-bases/b5829e4a-3845-4624-a7fb-ea3b35e843b0' \
+--header 'Content-Type: application/json' \
+--header 'X-API-Key: sk-vQHV2NZI_LK5W7wHQvH3yGYExX8YnhaHwZipUYbiZKCYJbBQ' \
+--data '{
+ "name": "weknora new",
+ "description": "weknora description new",
+ "config": {
+ "chunking_config": {
+ "chunk_size": 1000,
+ "chunk_overlap": 200,
+ "separators": [
+ "\n\n",
+ "\n",
+ "。",
+ "!",
+ "?",
+ ";",
+ ";"
+ ],
+ "enable_multimodal": true
+ },
+ "image_processing_config": {
+ "model_id": ""
+ }
+ }
+}'
```
**响应**:
```json
{
- "success": true,
- "data": {
- "id": "知识库ID",
- "tenant_id": 1,
- "name": "新知识库名称",
- "description": "新知识库描述",
- "config": {
- "chunk_size": 800,
- "chunk_overlap": 150
+ "data": {
+ "id": "b5829e4a-3845-4624-a7fb-ea3b35e843b0",
+ "name": "weknora new",
+ "description": "weknora description new",
+ "tenant_id": 1,
+ "chunking_config": {
+ "chunk_size": 1000,
+ "chunk_overlap": 200,
+ "separators": [
+ "\n\n",
+ "\n",
+ "。",
+ "!",
+ "?",
+ ";",
+ ";"
+ ],
+ "enable_multimodal": true
+ },
+ "image_processing_config": {
+ "model_id": ""
+ },
+ "embedding_model_id": "dff7bc94-7885-4dd1-bfd5-bd96e4df2fc3",
+ "summary_model_id": "8aea788c-bb30-4898-809e-e40c14ffb48c",
+ "rerank_model_id": "b30171a1-787b-426e-a293-735cd5ac16c0",
+ "vlm_model_id": "f2083ad7-63e3-486d-a610-e6c56e58d72e",
+ "vlm_config": {
+ "model_name": "qwen2.5vl:3b",
+ "base_url": "",
+ "api_key": "",
+ "interface_type": "ollama"
+ },
+ "cos_config": {
+ "secret_id": "",
+ "secret_key": "",
+ "region": "",
+ "bucket_name": "",
+ "app_id": "",
+ "path_prefix": ""
+ },
+ "created_at": "2025-08-12T11:30:09.206238+08:00",
+ "updated_at": "2025-08-12T11:36:09.083577609+08:00",
+ "deleted_at": null
},
- "embedding_model_id": "模型ID",
- "created_at": "2023-01-01T00:00:00Z",
- "updated_at": "2023-01-01T00:00:00Z"
- }
+ "success": true
}
```
#### DELETE `/knowledge-bases/:id` - 删除知识库
+**请求**:
+
+```curl
+curl --location --request DELETE 'http://localhost:8080/api/v1/knowledge-bases/b5829e4a-3845-4624-a7fb-ea3b35e843b0' \
+--header 'Content-Type: application/json' \
+--header 'X-API-Key: sk-vQHV2NZI_LK5W7wHQvH3yGYExX8YnhaHwZipUYbiZKCYJbBQ'
+```
+
**响应**:
```json
{
- "success": true
+ "message": "Knowledge base deleted successfully",
+ "success": true
}
```
#### GET `/knowledge-bases/:id/hybrid-search` - 混合搜索知识库内容
-**查询参数**:
+**请求**:
-- `query`: 搜索关键词(必填)
+```curl
+curl --location --request GET 'http://localhost:8080/api/v1/knowledge-bases/kb-00000001/hybrid-search' \
+--header 'Content-Type: application/json' \
+--header 'X-API-Key: sk-vQHV2NZI_LK5W7wHQvH3yGYExX8YnhaHwZipUYbiZKCYJbBQ' \
+--data '{
+ "query_text": "彗星",
+ "vector_threshold": 0.1,
+ "keyword_threshold": 0.1,
+ "match_count": 1
+}'
+```
**响应**:
```json
{
- "success": true,
- "data": [
- {
- "id": "分块ID",
- "content": "匹配到的内容片段",
- "metadata": {
- "source": "来源文件",
- "page": 1
- },
- "knowledge_title": "人工智能导论.pdf",
- "score": 0.92
- },
- {
- "id": "分块ID",
- "content": "匹配到的内容片段",
- "metadata": {
- "source": "来源文件",
- "page": 2
- },
- "knowledge_title": "人工智能导论.pdf",
- "score": 0.88
- }
- ]
+ "data": [
+ {
+ "id": "7d955251-3f79-4fd5-a6aa-02f81e044091",
+ "content": "有几位后来xxxxx",
+ "knowledge_id": "a6790b93-4700-4676-bd48-0d4804e1456b",
+ "chunk_index": 3,
+ "knowledge_title": "彗星.txt",
+ "start_at": 2287,
+ "end_at": 2760,
+ "seq": 3,
+ "score": 0.7402352891601821,
+ "match_type": 2,
+ "sub_chunk_id": null,
+ "metadata": {},
+ "chunk_type": "text",
+ "parent_chunk_id": "",
+ "image_info": "",
+ "knowledge_filename": "彗星.txt",
+ "knowledge_source": ""
+ }
+ ],
+ "success": true
}
```
@@ -433,39 +729,45 @@ WeKnora API 按功能分为以下几类:
#### POST `/knowledge-bases/:id/knowledge/file` - 从文件创建知识
-**请求格式**:
+**请求**:
-```
-Content-Type: multipart/form-data
-
-file: [上传的文件]
+```curl
+curl --location 'http://localhost:8080/api/v1/knowledge-bases/kb-00000001/knowledge/file' \
+--header 'Content-Type: application/json' \
+--header 'X-API-Key: sk-vQHV2NZI_LK5W7wHQvH3yGYExX8YnhaHwZipUYbiZKCYJbBQ' \
+--form 'file=@"/Users/xxxx/tests/彗星.txt"' \
+--form 'enable_multimodel="true"'
```
**响应**:
```json
{
- "success": true,
- "data": {
- "id": "4f0845e3-8f6e-4d5a-816b-196e34070617",
- "tenant_id": 1,
- "knowledge_base_id": "kb-00000003",
- "type": "file",
- "title": "彗星.txt",
- "description": "",
- "source": "",
- "parse_status": "failed",
- "enable_status": "disabled",
- "embedding_model_id": "model-embedding-00000001",
- "file_name": "彗星.txt",
- "file_type": "txt",
- "file_size": 7710,
- "file_path": "",
- "created_at": "2025-04-16T04:15:01.633797Z",
- "updated_at": "2025-04-16T04:15:03.24784Z",
- "processed_at": null,
- "error_message": "EmbedBatch API error: Http Status 403 Forbidden"
- }
+ "data": {
+ "id": "4c4e7c1a-09cf-485b-a7b5-24b8cdc5acf5",
+ "tenant_id": 1,
+ "knowledge_base_id": "kb-00000001",
+ "type": "file",
+ "title": "彗星.txt",
+ "description": "",
+ "source": "",
+ "parse_status": "processing",
+ "enable_status": "disabled",
+ "embedding_model_id": "dff7bc94-7885-4dd1-bfd5-bd96e4df2fc3",
+ "file_name": "彗星.txt",
+ "file_type": "txt",
+ "file_size": 7710,
+ "file_hash": "d69476ddbba45223a5e97e786539952c",
+ "file_path": "data/files/1/4c4e7c1a-09cf-485b-a7b5-24b8cdc5acf5/1754970756171067621.txt",
+ "storage_size": 0,
+ "metadata": null,
+ "created_at": "2025-08-12T11:52:36.168632288+08:00",
+ "updated_at": "2025-08-12T11:52:36.173612121+08:00",
+ "processed_at": null,
+ "error_message": "",
+ "deleted_at": null
+ },
+ "success": true
}
```
@@ -473,72 +775,92 @@ file: [上传的文件]
请求体:
-```json
-{
- "url": "https://example.com/document.pdf"
-}
+```curl
+curl --location 'http://localhost:8080/api/v1/knowledge-bases/kb-00000001/knowledge/url' \
+--header 'X-API-Key: sk-vQHV2NZI_LK5W7wHQvH3yGYExX8YnhaHwZipUYbiZKCYJbBQ' \
+--header 'Content-Type: application/json' \
+--data '{
+ "url":"https://github.com/Tencent/WeKnora",
+ "enable_multimodel":true
+}'
```
响应:
```json
{
- "success": true,
- "data": {
- "id": "4f0845e3-8f6e-4d5a-816b-196e34070617",
- "tenant_id": 1,
- "knowledge_base_id": "kb-00000003",
- "type": "file",
- "title": "彗星.txt",
- "description": "",
- "source": "",
- "parse_status": "failed",
- "enable_status": "disabled",
- "embedding_model_id": "model-embedding-00000001",
- "file_name": "彗星.txt",
- "file_type": "txt",
- "file_size": 7710,
- "file_path": "",
- "created_at": "2025-04-16T04:15:01.633797Z",
- "updated_at": "2025-04-16T04:15:03.24784Z",
- "processed_at": null,
- "error_message": "EmbedBatch API error: Http Status 403 Forbidden"
- }
+ "data": {
+ "id": "9c8af585-ae15-44ce-8f73-45ad18394651",
+ "tenant_id": 1,
+ "knowledge_base_id": "kb-00000001",
+ "type": "url",
+ "title": "",
+ "description": "",
+ "source": "https://github.com/Tencent/WeKnora",
+ "parse_status": "processing",
+ "enable_status": "disabled",
+ "embedding_model_id": "dff7bc94-7885-4dd1-bfd5-bd96e4df2fc3",
+ "file_name": "",
+ "file_type": "",
+ "file_size": 0,
+ "file_hash": "",
+ "file_path": "",
+ "storage_size": 0,
+ "metadata": null,
+ "created_at": "2025-08-12T11:55:05.709266776+08:00",
+ "updated_at": "2025-08-12T11:55:05.712918234+08:00",
+ "processed_at": null,
+ "error_message": "",
+ "deleted_at": null
+ },
+ "success": true
}
```
#### GET `/knowledge-bases/:id/knowledge?page=&page_size` - 获取知识库下的知识列表
+**请求**
+
+```curl
+curl --location 'http://localhost:8080/api/v1/knowledge-bases/kb-00000001/knowledge?page_size=1&page=1' \
+--header 'X-API-Key: sk-vQHV2NZI_LK5W7wHQvH3yGYExX8YnhaHwZipUYbiZKCYJbBQ' \
+--header 'Content-Type: application/json'
+```
+
响应:
```json
{
- "success": true,
- "data": [
- {
- "id": "4f0845e3-8f6e-4d5a-816b-196e34070617",
- "tenant_id": 1,
- "knowledge_base_id": "kb-00000003",
- "type": "file",
- "title": "彗星.txt",
- "description": "",
- "source": "",
- "parse_status": "failed",
- "enable_status": "disabled",
- "embedding_model_id": "model-embedding-00000001",
- "file_name": "彗星.txt",
- "file_type": "txt",
- "file_size": 7710,
- "file_path": "",
- "created_at": "2025-04-16T04:15:01.633797Z",
- "updated_at": "2025-04-16T04:15:03.24784Z",
- "processed_at": null,
- "error_message": "EmbedBatch API error: Http Status 403 Forbidden"
- }
- ],
- "total": 98,
- "page": 1,
- "page_size": 20
+ "data": [
+ {
+ "id": "9c8af585-ae15-44ce-8f73-45ad18394651",
+ "tenant_id": 1,
+ "knowledge_base_id": "kb-00000001",
+ "type": "url",
+ "title": "",
+ "description": "",
+ "source": "https://github.com/Tencent/WeKnora",
+ "parse_status": "pending",
+ "enable_status": "disabled",
+ "embedding_model_id": "dff7bc94-7885-4dd1-bfd5-bd96e4df2fc3",
+ "file_name": "",
+ "file_type": "",
+ "file_size": 0,
+ "file_hash": "",
+ "file_path": "",
+ "storage_size": 0,
+ "metadata": null,
+ "created_at": "2025-08-12T11:55:05.709266+08:00",
+ "updated_at": "2025-08-12T11:55:05.709266+08:00",
+ "processed_at": null,
+ "error_message": "",
+ "deleted_at": null
+ }
+ ],
+ "page": 1,
+ "page_size": 1,
+ "success": true,
+ "total": 2
}
```
@@ -546,100 +868,144 @@ file: [上传的文件]
#### GET `/knowledge/:id` - 获取知识详情
-响应:
+**请求**
+
+```curl
+curl --location 'http://localhost:8080/api/v1/knowledge/4c4e7c1a-09cf-485b-a7b5-24b8cdc5acf5' \
+--header 'X-API-Key: sk-vQHV2NZI_LK5W7wHQvH3yGYExX8YnhaHwZipUYbiZKCYJbBQ' \
+--header 'Content-Type: application/json'
+```
+
+**响应**
```json
{
- "success": true,
- "data": {
- "id": "4f0845e3-8f6e-4d5a-816b-196e34070617",
- "tenant_id": 1,
- "knowledge_base_id": "kb-00000003",
- "type": "file",
- "title": "彗星.txt",
- "description": "",
- "source": "",
- "parse_status": "failed",
- "enable_status": "disabled",
- "embedding_model_id": "model-embedding-00000001",
- "file_name": "彗星.txt",
- "file_type": "txt",
- "file_size": 7710,
- "file_path": "",
- "created_at": "2025-04-16T04:15:01.633797Z",
- "updated_at": "2025-04-16T04:15:03.24784Z",
- "processed_at": null,
- "error_message": "EmbedBatch API error: Http Status 403 Forbidden"
- }
+ "data": {
+ "id": "4c4e7c1a-09cf-485b-a7b5-24b8cdc5acf5",
+ "tenant_id": 1,
+ "knowledge_base_id": "kb-00000001",
+ "type": "file",
+ "title": "彗星.txt",
+ "description": "彗星是由冰和尘埃构成的太阳系小天体,接近太阳时会形成彗发和彗尾。其轨道周期差异大,来源包括柯伊伯带和奥尔特云。彗星与小行星的区别逐渐模糊,部分彗星已失去挥发物质,类似小行星。截至2019年,已知彗星超6600颗,数量庞大。彗星在古代被视为凶兆,现代研究揭示其复杂结构与起源。",
+ "source": "",
+ "parse_status": "completed",
+ "enable_status": "enabled",
+ "embedding_model_id": "dff7bc94-7885-4dd1-bfd5-bd96e4df2fc3",
+ "file_name": "彗星.txt",
+ "file_type": "txt",
+ "file_size": 7710,
+ "file_hash": "d69476ddbba45223a5e97e786539952c",
+ "file_path": "data/files/1/4c4e7c1a-09cf-485b-a7b5-24b8cdc5acf5/1754970756171067621.txt",
+ "storage_size": 33689,
+ "metadata": null,
+ "created_at": "2025-08-12T11:52:36.168632+08:00",
+ "updated_at": "2025-08-12T11:52:53.376871+08:00",
+ "processed_at": "2025-08-12T11:52:53.376573+08:00",
+ "error_message": "",
+ "deleted_at": null
+ },
+ "success": true
}
```
#### GET `/knowledge/batch` - 批量获取知识
-查询参数:
+**请求**
-- `ids`: 知识 ID 列表,例如:`?ids=knowledge_id_1&ids=knowledge_id_2`
+```curl
+curl --location 'http://localhost:8080/api/v1/knowledge/batch?ids=9c8af585-ae15-44ce-8f73-45ad18394651&ids=4c4e7c1a-09cf-485b-a7b5-24b8cdc5acf5' \
+--header 'X-API-Key: sk-vQHV2NZI_LK5W7wHQvH3yGYExX8YnhaHwZipUYbiZKCYJbBQ' \
+--header 'Content-Type: application/json'
+```
响应:
```json
{
- "success": true,
- "data": [
- {
- "id": "知识ID1",
- "tenant_id": 1,
- "knowledge_base_id": "知识库ID",
- "type": "file",
- "title": "文档1.pdf",
- "description": "",
- "source": "",
- "parse_status": "completed",
- "enable_status": "enabled",
- "embedding_model_id": "model-embedding-00000001",
- "file_name": "文档1.pdf",
- "file_type": "pdf",
- "file_size": 1024,
- "file_path": "",
- "created_at": "2023-01-01T00:00:00Z",
- "updated_at": "2023-01-01T00:00:00Z",
- "processed_at": "2023-01-01T00:00:01Z",
- "error_message": ""
- },
- {
- "id": "知识ID2",
- "tenant_id": 1,
- "knowledge_base_id": "知识库ID",
- "type": "url",
- "title": "网页文档",
- "description": "",
- "source": "https://example.com/doc",
- "parse_status": "completed",
- "enable_status": "enabled",
- "embedding_model_id": "model-embedding-00000001",
- "created_at": "2023-01-01T00:00:00Z",
- "updated_at": "2023-01-01T00:00:00Z",
- "processed_at": "2023-01-01T00:00:01Z",
- "error_message": ""
- }
- ]
+ "data": [
+ {
+ "id": "9c8af585-ae15-44ce-8f73-45ad18394651",
+ "tenant_id": 1,
+ "knowledge_base_id": "kb-00000001",
+ "type": "url",
+ "title": "",
+ "description": "",
+ "source": "https://github.com/Tencent/WeKnora",
+ "parse_status": "pending",
+ "enable_status": "disabled",
+ "embedding_model_id": "dff7bc94-7885-4dd1-bfd5-bd96e4df2fc3",
+ "file_name": "",
+ "file_type": "",
+ "file_size": 0,
+ "file_hash": "",
+ "file_path": "",
+ "storage_size": 0,
+ "metadata": null,
+ "created_at": "2025-08-12T11:55:05.709266+08:00",
+ "updated_at": "2025-08-12T11:55:05.709266+08:00",
+ "processed_at": null,
+ "error_message": "",
+ "deleted_at": null
+ },
+ {
+ "id": "4c4e7c1a-09cf-485b-a7b5-24b8cdc5acf5",
+ "tenant_id": 1,
+ "knowledge_base_id": "kb-00000001",
+ "type": "file",
+ "title": "彗星.txt",
+ "description": "彗星是由冰和尘埃构成的太阳系小天体,接近太阳时会形成彗发和彗尾。其轨道周期差异大,来源包括柯伊伯带和奥尔特云。彗星与小行星的区别逐渐模糊,部分彗星已失去挥发物质,类似小行星。截至2019年,已知彗星超6600颗,数量庞大。彗星在古代被视为凶兆,现代研究揭示其复杂结构与起源。",
+ "source": "",
+ "parse_status": "completed",
+ "enable_status": "enabled",
+ "embedding_model_id": "dff7bc94-7885-4dd1-bfd5-bd96e4df2fc3",
+ "file_name": "彗星.txt",
+ "file_type": "txt",
+ "file_size": 7710,
+ "file_hash": "d69476ddbba45223a5e97e786539952c",
+ "file_path": "data/files/1/4c4e7c1a-09cf-485b-a7b5-24b8cdc5acf5/1754970756171067621.txt",
+ "storage_size": 33689,
+ "metadata": null,
+ "created_at": "2025-08-12T11:52:36.168632+08:00",
+ "updated_at": "2025-08-12T11:52:53.376871+08:00",
+ "processed_at": "2025-08-12T11:52:53.376573+08:00",
+ "error_message": "",
+ "deleted_at": null
+ }
+ ],
+ "success": true
}
```
#### DELETE `/knowledge/:id` - 删除知识
+**请求**
+
+```curl
+curl --location --request DELETE 'http://localhost:8080/api/v1/knowledge/9c8af585-ae15-44ce-8f73-45ad18394651' \
+--header 'X-API-Key: sk-vQHV2NZI_LK5W7wHQvH3yGYExX8YnhaHwZipUYbiZKCYJbBQ' \
+--header 'Content-Type: application/json'
+```
+
响应:
```json
{
- "success": true,
- "message": "删除成功"
+ "message": "Deleted successfully",
+ "success": true
}
```
#### GET `/knowledge/:id/download` - 下载知识文件
-响应
+**请求**
+
+```curl
+curl --location 'http://localhost:8080/api/v1/knowledge/4c4e7c1a-09cf-485b-a7b5-24b8cdc5acf5/download' \
+--header 'X-API-Key: sk-vQHV2NZI_LK5W7wHQvH3yGYExX8YnhaHwZipUYbiZKCYJbBQ' \
+--header 'Content-Type: application/json'
+```
+
+**响应**
```
attachment
@@ -661,54 +1027,63 @@ attachment
创建对话模型(KnowledgeQA)请求体:
-```json
-{
- "name": "模型名称",
- "type": "KnowledgeQA",
- "source": "remote", # remote / local
- "description": "模型描述",
- "parameters": {
- "model": "gpt-4",
- "api_key": "sk-xxxxx",
- "base_url": "xxx"
- }
-}
+```curl
+curl --location 'http://localhost:8080/api/v1/models' \
+--header 'Content-Type: application/json' \
+--header 'X-API-Key: sk-vQHV2NZI_LK5W7wHQvH3yGYExX8YnhaHwZipUYbiZKCYJbBQ' \
+--data '{
+ "name": "qwen3:8b",
+ "type": "KnowledgeQA",
+ "source": "local",
+ "description": "LLM Model for Knowledge QA",
+ "parameters": {
+ "base_url": "",
+ "api_key": ""
+ },
+ "is_default": false
+}'
```
创建嵌入模型(Embedding)请求体:
-```json
-{
- "name": "模型名称",
- "type": "Embedding",
- "source": "remote", # remote / local
- "description": "模型描述",
- "parameters": {
- "model": "bge-m3",
- "api_key": "sk-xxxxx",
- "base_url": "xxx",
- "embedding_parameters": {
- "dimension": 768,
- "truncate_prompt_tokens": 512
- }
- }
-}
+```curl
+curl --location 'http://localhost:8080/api/v1/models' \
+--header 'Content-Type: application/json' \
+--header 'X-API-Key: sk-vQHV2NZI_LK5W7wHQvH3yGYExX8YnhaHwZipUYbiZKCYJbBQ' \
+--data '{
+ "name": "nomic-embed-text:latest",
+ "type": "Embedding",
+ "source": "local",
+ "description": "Embedding Model",
+ "parameters": {
+ "base_url": "",
+ "api_key": "",
+ "embedding_parameters": {
+ "dimension": 768,
+ "truncate_prompt_tokens": 0
+ }
+ },
+ "is_default": false
+}'
```
创建排序模型(Rerank)请求体:
-```json
-{
- "name": "模型名称",
- "type": "Rerank",
- "source": "remote", # remote / local
- "description": "模型描述",
- "parameters": {
- "model": "gte-reranker",
- "api_key": "sk-xxxxx",
- "base_url": "xxx"
- }
-}
+```curl
+curl --location 'http://localhost:8080/api/v1/models' \
+--header 'Content-Type: application/json' \
+--header 'X-API-Key: sk-vQHV2NZI_LK5W7wHQvH3yGYExX8YnhaHwZipUYbiZKCYJbBQ' \
+--data '{
+ "name": "linux6200/bge-reranker-v2-m3:latest",
+ "type": "Rerank",
+ "source": "local",
+ "description": "Rerank Model for Knowledge QA",
+ "parameters": {
+ "base_url": "",
+ "api_key": ""
+ },
+ "is_default": false
+}'
```
@@ -716,89 +1091,128 @@ attachment
```json
{
- "success": true,
- "data": {
- "id": "模型ID",
- "tenant_id": 1,
- "name": "模型名称",
- "type": "LLM",
- "source": "OPENAI",
- "description": "模型描述",
- "parameters": {
- "model": "gpt-4",
- "api_key": "sk-xxxxx",
- "base_url": "https://api.openai.com"
+ "data": {
+ "id": "09c5a1d6-ee8b-4657-9a17-d3dcbd5c70cb",
+ "tenant_id": 1,
+ "name": "nomic-embed-text:latest3",
+ "type": "Embedding",
+ "source": "local",
+ "description": "Embedding Model",
+ "parameters": {
+ "base_url": "",
+ "api_key": "",
+ "embedding_parameters": {
+ "dimension": 768,
+ "truncate_prompt_tokens": 0
+ }
+ },
+ "is_default": false,
+ "status": "downloading",
+ "created_at": "2025-08-12T10:39:01.454591766+08:00",
+ "updated_at": "2025-08-12T10:39:01.454591766+08:00",
+ "deleted_at": null
},
- "created_at": "2023-01-01T00:00:00Z",
- "updated_at": "2023-01-01T00:00:00Z"
- }
+ "success": true
}
```
#### GET `/models` - 获取模型列表
-响应:
+**请求**
+```curl
+curl --location 'http://localhost:8080/api/v1/models' \
+--header 'Content-Type: application/json' \
+--header 'X-API-Key: sk-vQHV2NZI_LK5W7wHQvH3yGYExX8YnhaHwZipUYbiZKCYJbBQ'
+```
+
+**响应**
```json
{
- "success": true,
- "data": [
- {
- "id": "模型ID1",
- "tenant_id": 1,
- "name": "模型1",
- "type": "LLM",
- "source": "OPENAI",
- "description": "模型1描述",
- "parameters": {
- "model": "gpt-4",
- "api_key": "sk-xxxxx",
- "base_url": "https://api.openai.com"
- },
- "created_at": "2023-01-01T00:00:00Z",
- "updated_at": "2023-01-01T00:00:00Z"
- },
- {
- "id": "模型ID2",
- "tenant_id": 1,
- "name": "模型2",
- "type": "EMBEDDING",
- "source": "OPENAI",
- "description": "模型2描述",
- "parameters": {
- "model": "text-embedding-ada-002",
- "api_key": "sk-xxxxx",
- "base_url": "https://api.openai.com"
- },
- "created_at": "2023-01-01T00:00:00Z",
- "updated_at": "2023-01-01T00:00:00Z"
- }
- ]
+ "data": [
+ {
+ "id": "dff7bc94-7885-4dd1-bfd5-bd96e4df2fc3",
+ "tenant_id": 1,
+ "name": "nomic-embed-text:latest",
+ "type": "Embedding",
+ "source": "local",
+ "description": "Embedding Model",
+ "parameters": {
+ "base_url": "",
+ "api_key": "",
+ "embedding_parameters": {
+ "dimension": 768,
+ "truncate_prompt_tokens": 0
+ }
+ },
+ "is_default": true,
+ "status": "active",
+ "created_at": "2025-08-11T20:10:41.813832+08:00",
+ "updated_at": "2025-08-11T20:10:41.822354+08:00",
+ "deleted_at": null
+ },
+ {
+ "id": "8aea788c-bb30-4898-809e-e40c14ffb48c",
+ "tenant_id": 1,
+ "name": "qwen3:8b",
+ "type": "KnowledgeQA",
+ "source": "local",
+ "description": "LLM Model for Knowledge QA",
+ "parameters": {
+ "base_url": "",
+ "api_key": "",
+ "embedding_parameters": {
+ "dimension": 0,
+ "truncate_prompt_tokens": 0
+ }
+ },
+ "is_default": true,
+ "status": "active",
+ "created_at": "2025-08-11T20:10:41.811761+08:00",
+ "updated_at": "2025-08-11T20:10:41.825381+08:00",
+ "deleted_at": null
+ }
+ ],
+ "success": true
}
```
#### GET `/models/:id` - 获取模型详情
-响应:
+**请求**
+
+```curl
+curl --location 'http://localhost:8080/api/v1/models/dff7bc94-7885-4dd1-bfd5-bd96e4df2fc3' \
+--header 'Content-Type: application/json' \
+--header 'X-API-Key: sk-vQHV2NZI_LK5W7wHQvH3yGYExX8YnhaHwZipUYbiZKCYJbBQ'
+```
+
+**响应**
```json
{
- "success": true,
- "data": {
- "id": "模型ID",
- "tenant_id": 1,
- "name": "模型名称",
- "type": "LLM",
- "source": "OPENAI",
- "description": "模型描述",
- "parameters": {
- "model": "gpt-4",
- "api_key": "sk-xxxxx",
- "base_url": "https://api.openai.com"
+ "data": {
+ "id": "dff7bc94-7885-4dd1-bfd5-bd96e4df2fc3",
+ "tenant_id": 1,
+ "name": "nomic-embed-text:latest",
+ "type": "Embedding",
+ "source": "local",
+ "description": "Embedding Model",
+ "parameters": {
+ "base_url": "",
+ "api_key": "",
+ "embedding_parameters": {
+ "dimension": 768,
+ "truncate_prompt_tokens": 0
+ }
+ },
+ "is_default": true,
+ "status": "active",
+ "created_at": "2025-08-11T20:10:41.813832+08:00",
+ "updated_at": "2025-08-11T20:10:41.822354+08:00",
+ "deleted_at": null
},
- "created_at": "2023-01-01T00:00:00Z",
- "updated_at": "2023-01-01T00:00:00Z"
- }
+ "success": true
}
```
@@ -806,51 +1220,66 @@ attachment
请求体:
-```json
-{
- "name": "新模型名称",
- "description": "新模型描述",
- "parameters": {
- "model": "gpt-4-turbo",
- "api_key": "sk-xxxxx",
- "base_url": "https://api.openai.com"
- },
- "is_default": false
-}
+```curl
+curl --location --request PUT 'http://localhost:8080/api/v1/models/8fdc464d-8eaa-44d4-a85b-094b28af5330' \
+--header 'Content-Type: application/json' \
+--header 'X-API-Key: sk-vQHV2NZI_LK5W7wHQvH3yGYExX8YnhaHwZipUYbiZKCYJbBQ' \
+--data '{
+ "name": "linux6200/bge-reranker-v2-m3:latest",
+ "description": "Rerank Model for Knowledge QA new",
+ "parameters": {
+ "base_url": "",
+ "api_key": ""
+ },
+ "is_default": false
+}'
```
响应:
```json
{
- "success": true,
- "data": {
- "id": "模型ID",
- "tenant_id": 1,
- "name": "新模型名称",
- "type": "LLM",
- "source": "OPENAI",
- "description": "新模型描述",
- "parameters": {
- "model": "gpt-4-turbo",
- "api_key": "sk-xxxxx",
- "base_url": "https://api.openai.com"
+ "data": {
+ "id": "8fdc464d-8eaa-44d4-a85b-094b28af5330",
+ "tenant_id": 1,
+ "name": "linux6200/bge-reranker-v2-m3:latest",
+ "type": "Rerank",
+ "source": "local",
+ "description": "Rerank Model for Knowledge QA new",
+ "parameters": {
+ "base_url": "",
+ "api_key": "",
+ "embedding_parameters": {
+ "dimension": 0,
+ "truncate_prompt_tokens": 0
+ }
+ },
+ "is_default": false,
+ "status": "active",
+ "created_at": "2025-08-12T10:57:39.512681+08:00",
+ "updated_at": "2025-08-12T11:00:27.271678+08:00",
+ "deleted_at": null
},
- "is_default": false,
- "created_at": "2023-01-01T00:00:00Z",
- "updated_at": "2023-01-01T00:00:00Z"
- }
+ "success": true
}
```
#### DELETE `/models/:id` - 删除模型
-响应:
+**请求**
+
+```curl
+curl --location --request DELETE 'http://localhost:8080/api/v1/models/8fdc464d-8eaa-44d4-a85b-094b28af5330' \
+--header 'Content-Type: application/json' \
+--header 'X-API-Key: sk-vQHV2NZI_LK5W7wHQvH3yGYExX8YnhaHwZipUYbiZKCYJbBQ'
+```
+
+**响应**
```json
{
- "success": true,
- "message": "模型删除成功"
+ "message": "Model deleted",
+ "success": true
}
```
@@ -861,100 +1290,88 @@ attachment
| 方法 | 路径 | 描述 |
| ------ | --------------------------- | ------------------------ |
| GET | `/chunks/:knowledge_id` | 获取知识的分块列表 |
-| PUT | `/chunks/:knowledge_id/:id` | 更新分块 |
| DELETE | `/chunks/:knowledge_id/:id` | 删除分块 |
| DELETE | `/chunks/:knowledge_id` | 删除知识下的所有分块 |
#### GET `/chunks/:knowledge_id?page=&page_size=` - 获取知识的分块列表
-查询参数:
+**请求**
-- `page`: 页码(默认 1)
-- `page_size`: 每页条数(默认 20)
+```curl
+curl --location 'http://localhost:8080/api/v1/chunks/4c4e7c1a-09cf-485b-a7b5-24b8cdc5acf5?page=1&page_size=1' \
+--header 'X-API-Key: sk-vQHV2NZI_LK5W7wHQvH3yGYExX8YnhaHwZipUYbiZKCYJbBQ' \
+--header 'Content-Type: application/json'
+```
响应:
```json
{
- "success": true,
- "data": [
- {
- "id": "分块ID1",
- "knowledge_id": "知识ID",
- "content": "分块1内容...",
- "is_enabled": true,
- "created_at": "2023-01-01T00:00:00Z",
- "updated_at": "2023-01-01T00:00:00Z"
- },
- {
- "id": "分块ID2",
- "knowledge_id": "知识ID",
- "content": "分块2内容...",
- "is_enable": true,
- "created_at": "2023-01-01T00:00:00Z",
- "updated_at": "2023-01-01T00:00:00Z"
- }
- ],
- "total": 50,
- "page": 1,
- "page_size": 20
-}
-```
-
-#### PUT `/chunks/:knowledge_id/:id` - 更新分块
-
-请求体:
-
-```json
-{
- "content": "更新后的分块内容",
- "metadata": {
+ "data": [
+ {
+ "id": "df10b37d-cd05-4b14-ba8a-e1bd0eb3bbd7",
+ "tenant_id": 0,
+ "knowledge_id": "4c4e7c1a-09cf-485b-a7b5-24b8cdc5acf5",
+ "knowledge_base_id": "kb-00000001",
+ "content": "彗星xxxx",
+ "chunk_index": 0,
+ "is_enabled": true,
+ "start_at": 0,
+ "end_at": 964,
+ "pre_chunk_id": "",
+ "next_chunk_id": "",
+ "chunk_type": "text",
+ "parent_chunk_id": "",
+ "relation_chunks": null,
+ "indirect_relation_chunks": null,
+ "image_info": "",
+ "created_at": "0001-01-01T00:00:00Z",
+ "updated_at": "0001-01-01T00:00:00Z",
+ "deleted_at": null
+ }
+ ],
"page": 1,
- "position": "top",
- "custom_field": "自定义字段"
- }
-}
-```
-
-响应:
-
-```json
-{
- "success": true,
- "data": {
- "id": "分块ID",
- "knowledge_id": "知识ID",
- "content": "更新后的分块内容",
- "metadata": {
- "page": 1,
- "position": "top",
- "custom_field": "自定义字段"
- },
- "created_at": "2023-01-01T00:00:00Z",
- "updated_at": "2023-01-01T00:00:00Z"
- }
+ "page_size": 1,
+ "success": true,
+ "total": 5
}
```
#### DELETE `/chunks/:knowledge_id/:id` - 删除分块
-响应:
+**请求**
+
+```curl
+curl --location --request DELETE 'http://localhost:8080/api/v1/chunks/4c4e7c1a-09cf-485b-a7b5-24b8cdc5acf5/df10b37d-cd05-4b14-ba8a-e1bd0eb3bbd7' \
+--header 'X-API-Key: sk-vQHV2NZI_LK5W7wHQvH3yGYExX8YnhaHwZipUYbiZKCYJbBQ' \
+--header 'Content-Type: application/json'
+```
+
+**响应**:
```json
{
- "success": true,
- "message": "分块删除成功"
+ "message": "Chunk deleted",
+ "success": true
}
```
#### DELETE `/chunks/:knowledge_id` - 删除知识下的所有分块
-响应:
+**请求**
+
+```curl
+curl --location --request DELETE 'http://localhost:8080/api/v1/chunks/4c4e7c1a-09cf-485b-a7b5-24b8cdc5acf5' \
+--header 'X-API-Key: sk-vQHV2NZI_LK5W7wHQvH3yGYExX8YnhaHwZipUYbiZKCYJbBQ' \
+--header 'Content-Type: application/json'
+```
+
+**响应**:
```json
{
- "success": true,
- "message": "所有分块删除成功"
+ "message": "All chunks under knowledge deleted",
+ "success": true
}
```
@@ -976,208 +1393,296 @@ attachment
请求体:
-```json
-{
- "knowledge_base_id": "知识库ID",
- "session_strategy": {
- "max_rounds": 5,
- "enable_rewrite": true,
- "fallback_strategy": "FIXED_RESPONSE",
- "fallback_response": "对不起,我无法回答这个问题",
- "keyword_threshold": 0.5,
- "vector_threshold": 0.7,
- "rerank_model_id": "排序模型ID",
- "rerank_top_k": 3,
- "summary_model_id": "总结模型ID",
- "summary_parameters": {
- "max_tokens": 100,
- "top_p": 0.9,
- "top_k": 40,
- "frequency_penalty": 0.0,
- "presence_penalty": 0.0,
- "repeat_penalty": 1.1,
- "prompt": "总结对话内容",
- "context_template": "上下文模板"
+```curl
+curl --location 'http://localhost:8080/api/v1/sessions' \
+--header 'X-API-Key: sk-vQHV2NZI_LK5W7wHQvH3yGYExX8YnhaHwZipUYbiZKCYJbBQ' \
+--header 'Content-Type: application/json' \
+--data '{
+ "knowledge_base_id": "kb-00000001",
+ "session_strategy": {
+ "max_rounds": 5,
+ "enable_rewrite": true,
+ "fallback_strategy": "FIXED_RESPONSE",
+ "fallback_response": "对不起,我无法回答这个问题",
+ "embedding_top_k": 10,
+ "keyword_threshold": 0.5,
+ "vector_threshold": 0.7,
+ "rerank_model_id": "排序模型ID",
+ "rerank_top_k": 3,
+ "rerank_threshold": 0.7,
+ "summary_model_id": "8aea788c-bb30-4898-809e-e40c14ffb48c",
+ "summary_parameters": {
+ "max_tokens": 0,
+ "repeat_penalty": 1,
+ "top_k": 0,
+ "top_p": 0,
+ "frequency_penalty": 0,
+ "presence_penalty": 0,
+ "prompt": "这是用户和助手之间的对话。xxx",
+ "context_template": "你是一个专业的智能信息检索助手xxx",
+ "no_match_prefix": "