import SGPClient from 'sgp';
const client = new SGPClient({
apiKey: 'My API Key',
});
// Automatically fetches more pages as needed.
for await (const knowledgeBase of client.knowledgeBases.list()) {
console.log(knowledgeBase.knowledge_base_id);
}{
"items": [
{
"knowledge_base_id": "<string>",
"vector_store_id": "<string>",
"knowledge_base_name": "<string>",
"embedding_config": {
"type": "<string>",
"model_deployment_id": "<string>"
},
"created_at": "<string>",
"metadata": {},
"updated_at": "<string>",
"connections": [
{
"last_uploaded_at": "2023-11-07T05:31:56Z",
"knowledge_base_data_source": {
"name": "<string>",
"data_source_config": {
"source": "<string>",
"s3_bucket": "<string>",
"aws_region": "<string>",
"aws_account_id": "<string>",
"s3_prefix": ""
},
"id": "<string>",
"created_at": "2023-11-07T05:31:56Z",
"updated_at": "2023-11-07T05:31:56Z",
"created_by_user_id": "<string>",
"created_by_identity_type": "user",
"account_id": "<string>",
"description": "<string>",
"tagging_information": {
"type": "all",
"tags_to_apply": {}
}
},
"deletion_status": "DELETING"
}
],
"artifacts_status": {
"artifacts_chunking": 123,
"artifacts_embedding": 123,
"artifacts_completed": 123,
"artifacts_pending": 123,
"artifacts_uploading": 123,
"artifacts_failed": 123
},
"artifact_count": 123,
"cluster_status": "<string>",
"created_by_user_id": "<string>"
}
],
"total_item_count": 123,
"current_page": 123,
"items_per_page": 123
}Lists all knowledge bases owned by the authorized user.
This API can be used to list all knowledge bases that have been created by the user. This API will return the details of all knowledge bases including their IDs, names, the embedding models they use, any metadata associated with the knowledge bases, and the timestamps for their creation, last-updated time.
V2 and V1 Knowledge Bases are entirely separate and not backwards compatible. Users who have existing V1 knowledge bases will need to migrate their data to V2 knowledge bases.
import SGPClient from 'sgp';
const client = new SGPClient({
apiKey: 'My API Key',
});
// Automatically fetches more pages as needed.
for await (const knowledgeBase of client.knowledgeBases.list()) {
console.log(knowledgeBase.knowledge_base_id);
}{
"items": [
{
"knowledge_base_id": "<string>",
"vector_store_id": "<string>",
"knowledge_base_name": "<string>",
"embedding_config": {
"type": "<string>",
"model_deployment_id": "<string>"
},
"created_at": "<string>",
"metadata": {},
"updated_at": "<string>",
"connections": [
{
"last_uploaded_at": "2023-11-07T05:31:56Z",
"knowledge_base_data_source": {
"name": "<string>",
"data_source_config": {
"source": "<string>",
"s3_bucket": "<string>",
"aws_region": "<string>",
"aws_account_id": "<string>",
"s3_prefix": ""
},
"id": "<string>",
"created_at": "2023-11-07T05:31:56Z",
"updated_at": "2023-11-07T05:31:56Z",
"created_by_user_id": "<string>",
"created_by_identity_type": "user",
"account_id": "<string>",
"description": "<string>",
"tagging_information": {
"type": "all",
"tags_to_apply": {}
}
},
"deletion_status": "DELETING"
}
],
"artifacts_status": {
"artifacts_chunking": 123,
"artifacts_embedding": 123,
"artifacts_completed": 123,
"artifacts_pending": 123,
"artifacts_uploading": 123,
"artifacts_failed": 123
},
"artifact_count": 123,
"cluster_status": "<string>",
"created_by_user_id": "<string>"
}
],
"total_item_count": 123,
"current_page": 123,
"items_per_page": 123
}Optional search by account_id
Connections, ArtifactCount Optional search by knowledge base name (case-insensitive partial match)
Page number for pagination to be returned by the given endpoint. Starts at page 1
x >= 1Maximum number of artifacts to be returned by the given endpoint. Defaults to 100 and cannot be greater than 10k.
1 <= x <= 10000Successful Response
The data returned for the current page.
Show child attributes
The unique ID of the knowledge base
(Legacy) The unique ID of the underlying vector store. This is to allow for backwards compatibility with the V1 Vector Store APIs. This will be removed in the near future.
The name of the knowledge base
The embedding configuration
The timestamp at which the knowledge base was created
Metadata associated with the knowledge base
The timestamp at which the knowledge base was last updated
The data source connections associated with the knowledge base. Only returned with the view=Connections query parameter.
Show child attributes
The date and time when the last upload for the data source was initiated.
The knowledge base data source entity.
Show child attributes
Show child attributes
"S3"Name of the S3 bucket where the data is stored.
AWS region where the S3 bucket is located.
AWS account ID that owns the S3 bucket.
Prefix of the S3 bucket where the data is stored. If not specified, the entire bucket will be used.
The unique identifier of the entity.
The date and time when the entity was created in ISO format.
The date and time when the entity was last updated in ISO format.
The user who originally created the entity.
The type of identity that created the entity.
user, service_account The ID of the account that owns the given entity.
The status of the deletion job for this data source connection, if any.
DELETING, FAILED Number of artifacts in each of the various states, such as completed and failed for this knowledge base. This includes all data sources.
Show child attributes
Number of artifacts in the chunking state
Number of artifacts in the embedding state
Number of artifacts uploaded successfully.
Previously: Number of artifacts awaiting upload. Note that this status will be deprecated soon and should show 0
Number of artifacts with upload in progress.
Number of artifacts that failed while being processed.
The total number of artifacts in the knowledge base. Only returned with the view=ArtifactCount query parameter.
Whether the knowledge base has been clustered.
The user ID of the user who created the knowledge base.
The total number of items of the query
The current page number.
The number of items per page.