Check if the data source has been added¶
Checks whether the requested catalog file and table already exist in the knowledge base as a data source. Use this interface to remove duplicates before adding sources.
POST https://moi.matrixorigin.cn/newmoi/semantic-models/{model_id}/sources/existence
Preparation before calling¶
First confirm the identification of the files and tables to be checked in the Catalog. Prepare a personal access token and target workspace ID that has access to the target workspace.
The example below uses:
$AI_STUDIO_API_KEY: The actual personal access token, passed through theX-API-KeyHeader.$WORKSPACE_ID: Target workspace ID, passed throughX-Workspace-IDHeader.$MODEL_ID: The knowledge base ID to check.$FILE_ID: Catalog file ID to check.$TABLE_ID: Catalog table ID to check.
Request example¶
curl -X POST "https://moi.matrixorigin.cn/newmoi/semantic-models/$MODEL_ID/sources/existence" \
-H "X-API-Key: $AI_STUDIO_API_KEY" \
-H "X-Workspace-ID: $WORKSPACE_ID" \
-H 'Content-Type: application/json' \
-d '{
"file_ids": ["'"$FILE_ID"'"],
"table_ids": ['"$TABLE_ID"']
}'
Path parameters¶
Parameter |
Type |
Required |
Description |
|---|---|---|---|
|
integer |
Yes |
The knowledge base ID of the data source to be checked. |
Request body¶
Field |
Type |
Required |
Description |
|---|---|---|---|
|
array[string] |
No |
The file ID to check. |
|
array[integer] |
No |
The table ID to check. |
Successful response¶
Returns 200 on success, and only returns request IDs that already exist in the knowledge base. Remove these duplicates from the to-be-added list before adding the source.
{
"code": "OK",
"msg": "OK",
"data": {
"file_ids": ["file_01"],
"table_ids": [456]
}
}
The response fields are as follows.
Field |
Type |
Description |
|---|---|---|
|
string |
|
|
string |
|
|
string[] |
Among the requested file IDs, the ID already exists as the source. |
|
integer[] |
The ID of the requested table ID that already exists as a source. |
[] after a type means an array. For example, string[] is an array of strings.
Error response¶
{
"code": "ErrParamInvalid",
"msg": "invalid source identifiers",
"data": null
}
Common HTTP errors¶
HTTP status code |
error code |
Common causes |
Recommended actions |
|---|---|---|---|
|
|
Invalid |
Correct the request parameters and try again. |
|
|
The API Key is invalid or has expired. |
Check API Key. |
|
|
The caller does not have permission to read the source or knowledge base. |
Check workspace and object authorization. |
|
|
The knowledge base does not exist or is not visible. |
Reconfirm |
|
|
The service failed to check the source. |
Keep the desensitized response information and try again. |
Follow-up operations¶
Add data source after removing duplicates.