Update segments¶
Updates the contents of the specified segment in the current snapshot. Use ETag to avoid overwriting other callers’ changes.
PATCH $CLOUDSIGMA_API_BASE/semantic-models/{model_id}/sources/{source_row_id}/segments/{segment_id}
Before you call¶
Configure the CloudSigma regional endpoint and authentication before calling. The endpoint, credentials, workspace, and resource IDs must belong to the same region.
First query the knowledge base document details, and obtain data.etag and the segment ID to be updated. Prepare a personal access token and target workspace ID that can access the target workspace.
The source must be a file source, have kb_file_id, and have a vector index available. Table sources do not support segmented writes.
Request body¶
curl -X PATCH "$CLOUDSIGMA_API_BASE/semantic-models/$MODEL_ID/sources/$SOURCE_ROW_ID/segments/$SEGMENT_ID" \
-H "X-API-Key: $CLOUDSIGMA_API_KEY" \
-H "X-Workspace-ID: $WORKSPACE_ID" \
-H 'Content-Type: application/json' \
-d '{
"if_match": "<DOCUMENT_ETAG>",
"content": "<SEGMENT_CONTENT>"
}'
Path parameters
Field |
Type |
Required |
Description |
|---|---|---|---|
|
integer |
Yes |
knowledge base ID. |
|
string |
Yes |
Source record ID. |
|
string |
Yes |
The segment ID to update. |
Request body
Submit the ETag of the current snapshot, along with the text, OCR text, or image description to be updated. When the request body does not provide a non-empty if_match, the ETag can be passed in through the If-Match request header. Provide at least one. When both are provided, the request body takes precedence.
Field |
Type |
Required |
Description |
|---|---|---|---|
|
string |
Conditional |
|
|
string |
No |
Updated text content. |
|
string |
No |
Updated OCR text. |
|
string |
No |
Updated image description. |
Successful response¶
{
"code": "OK",
"msg": "OK",
"data": {
"document": {
"source": {
"row_id": "src_01",
"model_id": 401
},
"segment_status": {
"available": true,
"total": 2
},
"etag": "<NEW_DOCUMENT_ETAG>",
"segments": [
{
"segment_id": "seg_01",
"level": "chunk",
"content": "更新后的文本",
"enabled": true
}
]
}
}
}
Field |
Type |
Description |
|---|---|---|
|
string |
|
|
string |
|
|
object |
The return data of this operation. |
|
object |
Updated source document snapshot. |
|
object |
Source records. For complete fixed fields, see Query document details’s |
|
object |
Source content preview. Contains |
|
object |
File information. Contains label, expiration and activation status. For fields, see Query Document Details. |
|
object |
Current segment availability status and total number. |
|
string |
The ETag of the current snapshot. Returned when there is a value, used for subsequent condition writing. |
|
array of object |
The segments in the current snapshot. Fixed subfields are shown in the following segmented fields on this page. |
|
string |
Source record ID. |
|
integer |
Belonging knowledge base ID. |
|
boolean |
Whether the segment is available. |
|
string |
The reason why the segment is unavailable. Returned if there is a value. |
|
integer |
The current number of segments. |
|
string |
Segment ID. |
|
integer |
Starting time or location. Returned if there is a value. |
|
integer |
End time or location. Returned if there is a value. |
|
string |
Segment level. |
|
integer |
Segment number. Returned if there is a value. |
|
string |
Block ID. Returned if there is a value. |
|
string |
Updated segmented text. May be omitted if content is not returned. |
|
string |
OCR text. Returned if there is a value. |
|
string |
Image description. Returned if there is a value. |
|
string |
Image file ID. Returned if there is a value. |
|
string |
Page image file ID. Returned if there is a value. |
|
integer |
Number of Unicode characters combined for text, OCR text, and image descriptions, including delimiting newlines. |
|
integer |
Number of recalls. |
|
boolean |
Whether the segment participates in retrieval. |
|
object |
Information about the source volume. Returned when |
Error response¶
Returns 400 and ErrParamInvalid when no valid ETag is provided. When the ETag is inconsistent with the current snapshot, 409 and ErrConflict are returned. An error description is returned in the requested language.
{
"code": "ErrConflict",
"msg": "<ERROR_MESSAGE>",
"data": null
}
Field |
Type |
Description |
|---|---|---|
|
string |
error code. |
|
string |
Error description. |
|
null |
|