logo
开发者文档
搜索
获取知识文档列表

获取知识文档列表

获取 Agent 内的知识库的知识文档的列表。

请求方式

GET

调用地址

https://api-${endpoint}.gptbots.ai/v1/bot/doc/query/page

调用验证

详情参见 API 概述的鉴权方式说明。

请求

请求示例

curl -X GET 'https://api-${endpoint}.gptbots.ai/v1/bot/doc/query/page?page=1&page_size=10&knowledge_base_id=67457fea6f658672d6482542' \ -H 'Authorization: Bearer ${API Key}'
                      
                      curl -X GET 'https://api-${endpoint}.gptbots.ai/v1/bot/doc/query/page?page=1&page_size=10&knowledge_base_id=67457fea6f658672d6482542' \
-H 'Authorization: Bearer ${API Key}'

                    
此代码块在浮窗中显示

请求头

字段 类型 描述
Authorization Bearer ${API Key} 使用 Authorization: Bearer ${API Key}进行调用验证,请在 API 密钥页面获取密钥作为 API Key。

请求参数

字段 类型 必填 说明
knowledge_base_id String 是 知识库的 ID。
page Integer 是 页码,从 1 开始。
page_size Integer 是 每页的文档数。填写范围 10-100。

响应

响应示例

{ "list": [ { "id": "xxxxxx", "name": "My Doc", "format": "pdf", "source_url": "https://gptbots.ai/article_1.pdf", "status": "ACTIVE", "chunk": 100, "token": 1000000, "char_count": 10000000, "create_time": 1699843200, "update_time": 1699843200, "creator_id": "xxxxxx", "creator_email": "johnlee@gptbots.ai", "source_missing": false }, { "id": "xxxxxx", "name": "My Doc 2", "format": "txt", "source_url": "https://gptbots.ai/article_2.html", "status": "ACTIVE", "chunk": 100, "token": 1000000, "char_count": 10000000, "create_time": 1699843200, "update_time": 1699843200, "creator_id": "xxxxxx", "creator_email": "johnlee@gptbots.ai", "source_missing": true, "source_missing_reason": "NOT_FOUND" } ], "total": 100 }
                      
                      {
    "list": [
        {
            "id": "xxxxxx",
            "name": "My Doc",
            "format": "pdf",
            "source_url": "https://gptbots.ai/article_1.pdf",
            "status": "ACTIVE",
            "chunk": 100,
            "token": 1000000,
            "char_count": 10000000,
            "create_time": 1699843200,
            "update_time": 1699843200,
            "creator_id": "xxxxxx",
            "creator_email": "johnlee@gptbots.ai",
            "source_missing": false
        },
        {
            "id": "xxxxxx",
            "name": "My Doc 2",
            "format": "txt",
            "source_url": "https://gptbots.ai/article_2.html",
            "status": "ACTIVE",
            "chunk": 100,
            "token": 1000000,
            "char_count": 10000000,
            "create_time": 1699843200,
            "update_time": 1699843200,
            "creator_id": "xxxxxx",
            "creator_email": "johnlee@gptbots.ai",
            "source_missing": true,
            "source_missing_reason": "NOT_FOUND"
        }
    ],
    "total": 100
}

                    
此代码块在浮窗中显示

成功响应

字段 类型 说明
list Array<Object> 文档列表。
id String 文档的 ID。
name String 文档的名称。
format String 文档的格式。
source_url String 文档的来源地址。
status String 文档的状态。
chunk Integer 文档的知识块数。
token Integer 文档的 Token 数。
char_count Integer 文档的字符数。
create_time Long 文档的创建时间,时间戳。
update_time Long 文档的更新时间,时间戳。
creator_id String 文档创建人的 ID。
creator_email String 文档创建人的邮箱。
source_missing Boolean 源文件是否异常。仅 Google Drive 来源的文档返回该字段,其它来源不返回。任意一轮重新读到源文件会自动清除。
source_missing_reason String 源文件异常的原因,仅在 source_missing 为 true 时返回:TRASHED(文件已被移入 Google Drive 回收站)、PARENT_TRASHED(所在文件夹或某级父目录被移入回收站)——这两类的处置相同:向量搜索已自动关闭,从回收站还原后下次同步自动恢复,从首次发现它在回收站起,累计 3 轮同步且超过 24 小时仍在回收站,则会删除该知识文档;TRASH_PURGED(已从回收站中彻底删除,无法再还原,该知识文档随后会被移除)、NOT_FOUND(可能已被删除、取消共享,或当前授权的 Google 账号无权访问,无法区分,仅提示不处理)、ACCESS_DENIED(无权限访问,请检查共享设置,仅提示不处理)。后两类如果是近期切换过 Google 账号或调整过授权导致的,用能访问该文件的账号重新授权后,下次同步会自动清除。
total Integer 查询到的文档总数。

失败响应

字段 类型 描述
code Integer 错误码。
message String 错误详情。