Import initial segments¶
Import initial segments for the source. The current version baseline of the source must be read before calling; when the baseline does not match, the service refuses to write and the document details should be re-read.
POST $CLOUDSIGMA_API_BASE/semantic-models/{model_id}/sources/{source_row_id}/segments/import-initial
Before you call this API¶
Configure the regional API endpoint and authentication, and select the target workspace.
First query the document details, and obtain the current segment version ID and index version as the baseline.
Set the operation-specific values used in the request:
$MODEL_ID: Knowledge Base ID.$SOURCE_ROW_ID: Source record ID to import initial segment from.
This interface does not receive segment content; the service imports the initial segments available for this source based on the baseline.
Request¶
curl -X POST "$CLOUDSIGMA_API_BASE/semantic-models/$MODEL_ID/sources/$SOURCE_ROW_ID/segments/import-initial" \
-H "X-API-Key: $CLOUDSIGMA_API_KEY" \
-H "X-Workspace-ID: $WORKSPACE_ID" \
-H 'Content-Type: application/json' \
-d '{
"base_segment_version_id": "<SEGMENT_VERSION_ID>",
"base_index_version": <INDEX_VERSION>
}'
Path parameters
Parameters |
Type |
Description |
|---|---|---|
|
integer |
Knowledge base ID. |
|
string |
Source record ID to import the initial segment from. |
Request body
Field |
Type |
Required |
Description |
|---|---|---|---|
|
string |
Yes |
The current segment version ID read before the call. |
|
integer |
Yes |
The current index version read before the call. |
Successful response¶
Returns 200 and the updated source document snapshot on success.
{
"code": "OK",
"msg": "OK",
"data": {
"document": {
"source": {
"row_id": "src_01",
"model_id": 401,
"ingest_status": "ready"
},
"segment_status": {
"available": true,
"total": 2
},
"segment_versions": [
{
"version_id": "ver_02",
"current": true,
"chunk_count": 2
}
],
"segments": [
{
"segment_id": "seg_01",
"segment_type": "text",
"level": "chunk",
"content": "产品说明",
"enabled": true
}
]
}
}
}
The response fields are as follows.
Field |
Type |
Description |
|---|---|---|
|
string |
|
|
string |
|
|
object |
Snapshot of the updated source document. |
|
object |
Source record. |
|
boolean |
Whether segmented data is available. |
|
integer |
The number of segments that can currently be read. |
|
object[] |
A segmented version of this source. |
|
string |
Segment version ID. |
|
boolean |
Whether it is the current version. |
|
object[] |
Segmentation in the current version. |
|
string |
Segment ID. |
|
boolean |
Whether the segment participates in retrieval. |
In field paths, [] means each item in an array. For example, data.document.segment_versions[].version_id is the version_id field of each item in data.document.segment_versions.
Error response¶
{
"code": "ErrParamInvalid",
"msg": "invalid segment version baseline",
"data": null
}
Common HTTP errors¶
HTTP status code |
error code |
Common causes |
Recommended actions |
|---|---|---|---|
|
|
The path ID, request body, or staging version baseline is invalid. |
Submit using the current version information after re-reading the document. |
|
|
The API Key is invalid or has expired. |
Check API Key. |
|
|
The caller does not have permission to update this source. |
Check workspace and object authorization. |
|
|
The knowledge base or source does not exist or is not visible to the current caller. |
Reread source list to confirm ID. |
|
|
The current version has changed and the service refuses to write. |
Merge changes after reading the latest document and try again. |
|
|
The service failed to generate the initial segment. |
Keep the desensitized response information and try again. |
Follow-up operations¶
Query document details Confirm the imported segmented version.