列出相关文件
接口说明
分页读取与指定文件相关的文件,并返回可以继续读取正文的路径。
接口信息
| 字段 | 值 |
|---|---|
| 方法 | GET |
| 路径 | /openapi/v2/knowledge-bases/{knowledgeBaseId}/files/{fileId}/related |
| Operation ID | listRelatedFiles |
| 鉴权 | Bearer OpenAPI key |
入参
| 名称 | 位置 | 必填 | 类型 | 示例 | 说明 |
|---|---|---|---|---|---|
knowledgeBaseId | path | 是 | string | knowledge-base-11111111-1111-4111-8111-111111111111 | 知识库 API 返回的知识库标识。 |
fileId | path | 是 | string | source-file-11111111-1111-4111-8111-111111111111 | 文件树、搜索、相关文件或文件接口返回的可读取文件标识。 |
limit | query | 否 | integer | 50 | 最多返回的记录数量。部署环境可能采用更低的上限。 |
cursor | query | 否 | string | cursor_123 | 当前接口返回的下一页分页标记。 |
请求体
这个接口没有请求体。
请求示例
bash
curl -X GET "https://openapi.example.com/openapi/v2/knowledge-bases/knowledge-base-11111111-1111-4111-8111-111111111111/files/source-file-11111111-1111-4111-8111-111111111111/related?limit=50" \
-H "Authorization: Bearer <openapi-key>"成功响应
200
返回与指定当前可读取文件相关的文件分页。
| 字段 | 必填 | 类型 | 说明 |
|---|---|---|---|
activeContentRevision | 是 | integer | 当前可读取知识库内容的修订号。 |
fileId | 是 | string | 请求使用的文件标识。 |
sourceFileId | 是 | string | 与当前可读取文件对应的上传文件标识。 |
items | 是 | array<RelatedFile> | 当前分页中的记录。 |
nextCursor | 是 | string | null | 读取同一文件下一页相关结果时使用的分页标记。 |
message | 否 | string | null | 没有可用相关文件时返回的状态和后续建议。 |
nextActions | 否 | array<string> | 继续探索文件时建议执行的读取操作。 |
成功响应示例
json
{
"activeContentRevision": 1,
"fileId": "source-file-11111111-1111-4111-8111-111111111111",
"sourceFileId": "source-file-11111111-1111-4111-8111-111111111111",
"items": [
{
"activeContentRevision": 1,
"fileId": "source-file-22222222-2222-4222-8222-222222222222",
"sourceFileId": "source-file-22222222-2222-4222-8222-222222222222",
"path": "pages/reference.md",
"title": "Reference",
"relationType": "same_specific_subject",
"direction": "outgoing",
"fromFileId": "source-file-11111111-1111-4111-8111-111111111111",
"relationshipDepth": 1,
"reason": "Both files share body-derived subjects.",
"contentAvailable": true,
"readActions": {
"fileDetailById": "/openapi/v2/knowledge-bases/knowledge-base-11111111-1111-4111-8111-111111111111/files/source-file-22222222-2222-4222-8222-222222222222",
"fileContentById": "/openapi/v2/knowledge-bases/knowledge-base-11111111-1111-4111-8111-111111111111/files/source-file-22222222-2222-4222-8222-222222222222/content",
"fileContentByPath": "/openapi/v2/knowledge-bases/knowledge-base-11111111-1111-4111-8111-111111111111/files/content?path=pages%2Freference.md",
"relatedFilesById": "/openapi/v2/knowledge-bases/knowledge-base-11111111-1111-4111-8111-111111111111/files/source-file-22222222-2222-4222-8222-222222222222/related",
"graphExpansionByFileId": "/openapi/v2/knowledge-bases/knowledge-base-11111111-1111-4111-8111-111111111111/graph/expand?fileId=source-file-22222222-2222-4222-8222-222222222222",
"sourceFileStatusById": "/openapi/v2/knowledge-bases/knowledge-base-11111111-1111-4111-8111-111111111111/source-files/source-file-22222222-2222-4222-8222-222222222222"
}
}
],
"nextCursor": null
}错误码
下表列出这个接口已声明的全部错误响应。
| HTTP 状态 | 错误码 | 说明 |
|---|---|---|
| 401 | UNAUTHORIZED | Bearer API key 缺失、格式错误、未知、已撤销或已删除。 |
| 404 | NOT_FOUND | 请求的资源不存在。 |
| 409 | CONFLICT | 请求与资源当前状态冲突。 |
| 422 | VALIDATION_ERROR | 请求未通过校验。 |
| 429 | RATE_LIMITED | 请求超过当前配置的速率限制。 |
| 500 | INTERNAL_ERROR | API 遇到内部错误。 |
| 503 | DATABASE_REPOSITORY_UNAVAILABLE | 当前接口所需的数据暂时不可用。 |