Use the UpdateChunks operation to batch update the title, content, or status of slices. Batch requests may partially succeed. You must check the updateStatus field (succeed or failed) in data.updateDetails for each item. If an item fails, view the failureReason field.
Prerequisites
-
An AgentStorage instance has been created and is in the
normalstate, and you have obtained the instance endpoint and instance name. -
An API Key has been created.
-
The knowledge base and document to which the slices to be updated belong already exist.
Request parameters
|
Parameter |
Type |
Description |
|
|
string |
The name of the knowledge base. Required. |
|
|
string |
The subspace name. Required when subspace is enabled. |
|
|
list<object> |
The list of slices to update. Required. Maximum 10 per request. |
|
|
string |
The document ID. Either this or `ossKey` must be specified. |
|
|
string |
The OSS path. Either this or `docId` must be specified. |
|
|
int |
The slice ID. Required. |
|
|
string |
The updated title. Maximum 100 tokens. |
|
|
string |
The updated content. Maximum 512 tokens by default, calculated based on the server-side token count. If the instance has a custom quota configuration, the actual configuration applies. |
|
|
string |
The status to set: `active` (retrievable) or `inactive` (not retrievable). |
Request example
When you use API Key authentication, pass the instance name and API Key through the x-ots-instancename and x-ots-apikey request headers.
curl -X POST https://<endpoint>/UpdateChunks \
-H "x-ots-instancename: <instance-name>" \
-H "x-ots-apikey: <your-api-key>" \
-H "Content-Type: application/json" \
-d '{
"knowledgeBaseName": "product_docs_kb",
"subspace": "default",
"chunks": [
{"ossKey": "oss://example-bucket/docs/manual.pdf", "chunkId": 0, "status": "inactive"},
{"ossKey": "oss://example-bucket/docs/manual.pdf", "chunkId": 1, "title": "更新后的标题", "content": "更新后的内容"}
]
}'
Response
|
Field |
Type |
Description |
|
|
string |
The document ID. |
|
|
string |
The OSS path. |
|
|
int |
The slice ID. |
|
|
string |
succeed` or `failed |
|
|
string |
The failure reason. Returned only when the status is failed. |