logo
开发者文档
搜索
更新表格类文档

更新表格类文档

批量更新表格类型的文档,系统将依次执行分块/切片、嵌入/向量化,最后用新文档内容替换掉旧文档内容,但文档 ID 不变。

注意:
嵌入模型使用的是默认的模型,不可在 API 内定义。
仅返回上传结果,不返回最终的嵌入结果。您可以通过“查询文档状态”API 获取最终结果。

请求方式

PUT

调用地址

https://api-${endpoint}.gptbots.ai/v1/bot/doc/spreadsheet/update

调用验证

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

请求

请求示例

curl -X PUT 'https://api-${endpoint}.gptbots.ai/v1/bot/doc/spreadsheet/update' \ -H 'Authorization: Bearer ${API Key}' \ -H 'Content-Type: application/json' \ -d '{ "knowledge_base_id": "67457fea6f658672d6482542", "chunk_token": 700, "header_row": 5, "files": [ { "doc_id": "67457fea6f658672d6482542", "file_url": "https://www.gptbots.ai/doc/spreadsheet.xlsx", "source_url": "https://www.gptbots.ai/doc/spreadsheet.xlsx", "file_name": "spreadsheet_1.pdf" } ] }'
                      
                      curl -X PUT 'https://api-${endpoint}.gptbots.ai/v1/bot/doc/spreadsheet/update' \
-H 'Authorization: Bearer ${API Key}' \
-H 'Content-Type: application/json' \
-d '{
    "knowledge_base_id": "67457fea6f658672d6482542",
    "chunk_token": 700,
    "header_row": 5,
    "files": [
        {
            "doc_id": "67457fea6f658672d6482542",
            "file_url": "https://www.gptbots.ai/doc/spreadsheet.xlsx",
            "source_url": "https://www.gptbots.ai/doc/spreadsheet.xlsx",
            "file_name": "spreadsheet_1.pdf"
        }
    ]
}'

                    
此代码块在浮窗中显示

请求头

字段 类型 描述
Authorization Bearer ${API Key} 使用 Authorization: Bearer ${API Key} 进行调用验证,请在 API 密钥页面获取密钥作为 API Key。
Content-Type application/json 数据类型,取值为 application/json

请求体

字段 类型 必填 说明
files Array<Object> 更新的文档列表。最多支持同时更新 20 个文档。
doc_id String 更新的文档的 ID。
file_url String 添加的文档的 URL。 文档支持的格式:csv/xls/xlsx。每个文档最大 10MB。 注:URL 和 base64 二选一。当同时入参时,优先使用 base64。
file_base64 String 添加的文档的 base64。 文档支持的格式:csv/xls/xlsx。每个文档最大 10MB。 注:URL 和 base64 二选一。当同时入参时,优先使用 base64。
source_url String 更新的文档的来源 URL。必须符合 URL 格式规范。 若为空,则系统不对此值进行更新。 若需要将此值设置为空,请输入NULL
chunk_token Integer 分块时,单个知识块的最大 Token 数。默认值为 600。填写范围 1-1000。
header_row Integer 作为表头的最大行数。表格类文档以“表头+数据行”为单位进行分块。默认值为 1。填写范围 1-5。

响应

响应示例

{ "doc": [ { "doc_id": "xxxxxx", "doc_name": "test_1.csv" }, { "doc_id": "xxxxxx", "doc_name": "test_2.xlsx" } ], "failed": [ "xxxxxx", "xxxxxx" ] }
                      
                      {
    "doc": [
        {
            "doc_id": "xxxxxx",
            "doc_name": "test_1.csv"
        },
        {
            "doc_id": "xxxxxx",
            "doc_name": "test_2.xlsx"
        }
    ],
    "failed": [
        "xxxxxx",
        "xxxxxx"
    ]
}

                    
此代码块在浮窗中显示

成功响应

字段 类型 说明
doc Array<Object> 更新的文档列表。
doc_id String 更新的文档的 ID。
doc_name String 更新的文档的名称。
failed Array<Object> 更新失败的文档ID列表。

失败响应

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