Query document details¶
Query the current segment version, index version, and segment content of a source document. Use this interface to save the current version and index version before editing a segment.
GET $CLOUDSIGMA_API_BASE/semantic-models/{model_id}/sources/{source_row_id}/document
Before you call this API¶
Configure the regional API endpoint and authentication, and select the target workspace.
First query the data source list to obtain the source record ID.
Set the operation-specific values used in the request:
$MODEL_ID: Knowledge Base ID.$SOURCE_ROW_ID: Source record ID.$SEGMENT_VERSION_ID: The segment version ID to be read; if not passed, the current version is read.
Request¶
curl "$CLOUDSIGMA_API_BASE/semantic-models/$MODEL_ID/sources/$SOURCE_ROW_ID/document?segment_version_id=$SEGMENT_VERSION_ID" \
-H "X-API-Key: $CLOUDSIGMA_API_KEY" \
-H "X-Workspace-ID: $WORKSPACE_ID"
Path parameters
Parameters |
Type |
Description |
|---|---|---|
|
integer |
Knowledge base ID. |
|
string |
Source record ID. |
Query parameters
Parameter |
Type |
Required |
Description |
|---|---|---|---|
|
string |
No |
The segment version ID to be read; if not passed, the current version will be read. |
Successful response¶
Returns 200 on success. data Returns a document preview, version list, and segmented content for the selected version.
{
"code": "OK",
"msg": "OK",
"data": {
"source": {
"row_id": "src_01",
"model_id": 401,
"source_type": "file",
"ingest_status": "ready"
},
"preview": {
"available": true,
"content": "产品说明"
},
"file_info": {
"tags": ["product"],
"enabled": true,
"effective_enabled": true,
"index_version": 2,
"segment_version_id": "ver_02"
},
"segment_status": {
"available": true,
"total": 1
},
"current_segment_version_id": "ver_02",
"current_index_version": 2,
"segment_versions": [
{
"version_id": "ver_02",
"current": true,
"index_version": 2,
"chunk_count": 1
}
],
"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 |
Source record. |
|
boolean |
Whether preview content is available. |
|
string |
Preview content when available. |
|
string |
Reason the preview is unavailable, when applicable. |
|
object |
File tags, expiration and activation information. |
|
boolean |
Current actual effective status. |
|
boolean |
Whether segments are available. |
|
integer |
Number of segments. |
|
string |
Current segment version ID. |
|
integer |
Current index version. |
|
object[] |
All available segment versions; may be omitted if the source has not completed parsing or no segment versions have been generated. |
|
string |
Segment version ID. |
|
boolean |
Whether this is the current segment version. |
|
object[] |
Segments in the selected version. |
|
string |
Segment ID. |
|
string |
Segment content. |
|
boolean |
Whether the segment is enabled. |
In field paths, [] means each item in an array. For example, data.segment_versions[].version_id is the version_id field of each item in data.segment_versions.
Error response¶
{
"code": "ErrNotFound",
"msg": "resource not found",
"data": null
}
Common HTTP errors¶
HTTP status code |
error code |
Common causes |
Recommended actions |
|---|---|---|---|
|
|
|
Get the path ID from the source list. |
|
|
The API Key is invalid or has expired. |
Check API Key. |
|
|
The caller does not have permission to read the source document. |
Check workspace and object authorization. |
|
|
The knowledge base or source does not exist or is not visible to the current caller. |
Reconfirm the path ID. |
|
|
The service failed to read the document or segment. |
Keep the desensitized response information and try again. |
Follow-up operations¶
When you need to add content, Create segments; when modifying an existing segment, Update segments.