# Knowledge Bases ## Create `client.knowledgeBases.create(KnowledgeBaseCreateParamsbody?, RequestOptionsoptions?): KnowledgeBaseCreateResponse` **post** `/v2/gen-ai/knowledge_bases` To create a knowledge base, send a POST request to `/v2/gen-ai/knowledge_bases`. ### Parameters - `body: KnowledgeBaseCreateParams` - `database_id?: string` Identifier of the DigitalOcean OpenSearch database this knowledge base will use, optional. If not provided, we create a new database for the knowledge base in the same region as the knowledge base. - `datasources?: Array` The data sources to use for this knowledge base. See [Organize Data Sources](https://docs.digitalocean.com/products/genai-platform/concepts/best-practices/#spaces-buckets) for more information on data sources best practices. - `aws_data_source?: AwsDataSource` AWS S3 Data Source - `bucket_name?: string` Spaces bucket name - `item_path?: string` - `key_id?: string` The AWS Key ID - `region?: string` Region of bucket - `secret_key?: string` The AWS Secret Key - `bucket_name?: string` Deprecated, moved to data_source_details - `bucket_region?: string` Deprecated, moved to data_source_details - `dropbox_data_source?: DropboxDataSource` Dropbox Data Source - `folder?: string` - `refresh_token?: string` Refresh token. you can obrain a refresh token by following the oauth2 flow. see /v2/gen-ai/oauth2/dropbox/tokens for reference. - `file_upload_data_source?: APIFileUploadDataSource` File to upload as data source for knowledge base. - `original_file_name?: string` The original file name - `size_in_bytes?: string` The size of the file in bytes - `stored_object_key?: string` The object key the file was stored as - `item_path?: string` - `spaces_data_source?: APISpacesDataSource` Spaces Bucket Data Source - `bucket_name?: string` Spaces bucket name - `item_path?: string` - `region?: string` Region of bucket - `web_crawler_data_source?: APIWebCrawlerDataSource` WebCrawlerDataSource - `base_url?: string` The base url to crawl. - `crawling_option?: "UNKNOWN" | "SCOPED" | "PATH" | 2 more` Options for specifying how URLs found on pages should be handled. - UNKNOWN: Default unknown value - SCOPED: Only include the base URL. - PATH: Crawl the base URL and linked pages within the URL path. - DOMAIN: Crawl the base URL and linked pages within the same domain. - SUBDOMAINS: Crawl the base URL and linked pages for any subdomain. - `"UNKNOWN"` - `"SCOPED"` - `"PATH"` - `"DOMAIN"` - `"SUBDOMAINS"` - `embed_media?: boolean` Whether to ingest and index media (images, etc.) on web pages. - `embedding_model_uuid?: string` Identifier for the [embedding model](https://docs.digitalocean.com/products/genai-platform/details/models/#embedding-models). - `name?: string` Name of the knowledge base. - `project_id?: string` Identifier of the DigitalOcean project this knowledge base will belong to. - `region?: string` The datacenter region to deploy the knowledge base in. - `tags?: Array` Tags to organize your knowledge base. - `vpc_uuid?: string` The VPC to deploy the knowledge base database in ### Returns - `KnowledgeBaseCreateResponse` Information about a newly created knowledge base - `knowledge_base?: APIKnowledgeBase` Knowledgebase Description - `added_to_agent_at?: string` Time when the knowledge base was added to the agent - `created_at?: string` Creation date / time - `database_id?: string` - `embedding_model_uuid?: string` - `is_public?: boolean` Whether the knowledge base is public or not - `last_indexing_job?: APIIndexingJob` IndexingJob description - `completed_datasources?: number` Number of datasources indexed completed - `created_at?: string` Creation date / time - `data_source_uuids?: Array` - `finished_at?: string` - `knowledge_base_uuid?: string` Knowledge base id - `phase?: "BATCH_JOB_PHASE_UNKNOWN" | "BATCH_JOB_PHASE_PENDING" | "BATCH_JOB_PHASE_RUNNING" | 4 more` - `"BATCH_JOB_PHASE_UNKNOWN"` - `"BATCH_JOB_PHASE_PENDING"` - `"BATCH_JOB_PHASE_RUNNING"` - `"BATCH_JOB_PHASE_SUCCEEDED"` - `"BATCH_JOB_PHASE_FAILED"` - `"BATCH_JOB_PHASE_ERROR"` - `"BATCH_JOB_PHASE_CANCELLED"` - `started_at?: string` - `status?: "INDEX_JOB_STATUS_UNKNOWN" | "INDEX_JOB_STATUS_PARTIAL" | "INDEX_JOB_STATUS_IN_PROGRESS" | 4 more` - `"INDEX_JOB_STATUS_UNKNOWN"` - `"INDEX_JOB_STATUS_PARTIAL"` - `"INDEX_JOB_STATUS_IN_PROGRESS"` - `"INDEX_JOB_STATUS_COMPLETED"` - `"INDEX_JOB_STATUS_FAILED"` - `"INDEX_JOB_STATUS_NO_CHANGES"` - `"INDEX_JOB_STATUS_PENDING"` - `tokens?: number` Number of tokens - `total_datasources?: number` Number of datasources being indexed - `total_items_failed?: string` Total Items Failed - `total_items_indexed?: string` Total Items Indexed - `total_items_skipped?: string` Total Items Skipped - `updated_at?: string` Last modified - `uuid?: string` Unique id - `name?: string` Name of knowledge base - `project_id?: string` - `region?: string` Region code - `tags?: Array` Tags to organize related resources - `updated_at?: string` Last modified - `user_id?: string` Id of user that created the knowledge base - `uuid?: string` Unique id for knowledge base ### Example ```typescript import Gradient from '@digitalocean/gradient'; const client = new Gradient(); const knowledgeBase = await client.knowledgeBases.create(); console.log(knowledgeBase.knowledge_base); ``` ## Retrieve `client.knowledgeBases.retrieve(stringuuid, RequestOptionsoptions?): KnowledgeBaseRetrieveResponse` **get** `/v2/gen-ai/knowledge_bases/{uuid}` To retrive information about an existing knowledge base, send a GET request to `/v2/gen-ai/knowledge_bases/{uuid}`. ### Parameters - `uuid: string` ### Returns - `KnowledgeBaseRetrieveResponse` The knowledge base - `database_status?: "CREATING" | "ONLINE" | "POWEROFF" | 9 more` - `"CREATING"` - `"ONLINE"` - `"POWEROFF"` - `"REBUILDING"` - `"REBALANCING"` - `"DECOMMISSIONED"` - `"FORKING"` - `"MIGRATING"` - `"RESIZING"` - `"RESTORING"` - `"POWERING_ON"` - `"UNHEALTHY"` - `knowledge_base?: APIKnowledgeBase` Knowledgebase Description - `added_to_agent_at?: string` Time when the knowledge base was added to the agent - `created_at?: string` Creation date / time - `database_id?: string` - `embedding_model_uuid?: string` - `is_public?: boolean` Whether the knowledge base is public or not - `last_indexing_job?: APIIndexingJob` IndexingJob description - `completed_datasources?: number` Number of datasources indexed completed - `created_at?: string` Creation date / time - `data_source_uuids?: Array` - `finished_at?: string` - `knowledge_base_uuid?: string` Knowledge base id - `phase?: "BATCH_JOB_PHASE_UNKNOWN" | "BATCH_JOB_PHASE_PENDING" | "BATCH_JOB_PHASE_RUNNING" | 4 more` - `"BATCH_JOB_PHASE_UNKNOWN"` - `"BATCH_JOB_PHASE_PENDING"` - `"BATCH_JOB_PHASE_RUNNING"` - `"BATCH_JOB_PHASE_SUCCEEDED"` - `"BATCH_JOB_PHASE_FAILED"` - `"BATCH_JOB_PHASE_ERROR"` - `"BATCH_JOB_PHASE_CANCELLED"` - `started_at?: string` - `status?: "INDEX_JOB_STATUS_UNKNOWN" | "INDEX_JOB_STATUS_PARTIAL" | "INDEX_JOB_STATUS_IN_PROGRESS" | 4 more` - `"INDEX_JOB_STATUS_UNKNOWN"` - `"INDEX_JOB_STATUS_PARTIAL"` - `"INDEX_JOB_STATUS_IN_PROGRESS"` - `"INDEX_JOB_STATUS_COMPLETED"` - `"INDEX_JOB_STATUS_FAILED"` - `"INDEX_JOB_STATUS_NO_CHANGES"` - `"INDEX_JOB_STATUS_PENDING"` - `tokens?: number` Number of tokens - `total_datasources?: number` Number of datasources being indexed - `total_items_failed?: string` Total Items Failed - `total_items_indexed?: string` Total Items Indexed - `total_items_skipped?: string` Total Items Skipped - `updated_at?: string` Last modified - `uuid?: string` Unique id - `name?: string` Name of knowledge base - `project_id?: string` - `region?: string` Region code - `tags?: Array` Tags to organize related resources - `updated_at?: string` Last modified - `user_id?: string` Id of user that created the knowledge base - `uuid?: string` Unique id for knowledge base ### Example ```typescript import Gradient from '@digitalocean/gradient'; const client = new Gradient(); const knowledgeBase = await client.knowledgeBases.retrieve('"123e4567-e89b-12d3-a456-426614174000"'); console.log(knowledgeBase.database_status); ``` ## Update `client.knowledgeBases.update(stringpathUuid, KnowledgeBaseUpdateParamsbody?, RequestOptionsoptions?): KnowledgeBaseUpdateResponse` **put** `/v2/gen-ai/knowledge_bases/{uuid}` To update a knowledge base, send a PUT request to `/v2/gen-ai/knowledge_bases/{uuid}`. ### Parameters - `pathUuid: string` - `body: KnowledgeBaseUpdateParams` - `database_id?: string` The id of the DigitalOcean database this knowledge base will use, optiona. - `embedding_model_uuid?: string` Identifier for the foundation model. - `name?: string` Knowledge base name - `project_id?: string` The id of the DigitalOcean project this knowledge base will belong to - `tags?: Array` Tags to organize your knowledge base. - `body_uuid?: string` Knowledge base id ### Returns - `KnowledgeBaseUpdateResponse` Information about an updated knowledge base - `knowledge_base?: APIKnowledgeBase` Knowledgebase Description - `added_to_agent_at?: string` Time when the knowledge base was added to the agent - `created_at?: string` Creation date / time - `database_id?: string` - `embedding_model_uuid?: string` - `is_public?: boolean` Whether the knowledge base is public or not - `last_indexing_job?: APIIndexingJob` IndexingJob description - `completed_datasources?: number` Number of datasources indexed completed - `created_at?: string` Creation date / time - `data_source_uuids?: Array` - `finished_at?: string` - `knowledge_base_uuid?: string` Knowledge base id - `phase?: "BATCH_JOB_PHASE_UNKNOWN" | "BATCH_JOB_PHASE_PENDING" | "BATCH_JOB_PHASE_RUNNING" | 4 more` - `"BATCH_JOB_PHASE_UNKNOWN"` - `"BATCH_JOB_PHASE_PENDING"` - `"BATCH_JOB_PHASE_RUNNING"` - `"BATCH_JOB_PHASE_SUCCEEDED"` - `"BATCH_JOB_PHASE_FAILED"` - `"BATCH_JOB_PHASE_ERROR"` - `"BATCH_JOB_PHASE_CANCELLED"` - `started_at?: string` - `status?: "INDEX_JOB_STATUS_UNKNOWN" | "INDEX_JOB_STATUS_PARTIAL" | "INDEX_JOB_STATUS_IN_PROGRESS" | 4 more` - `"INDEX_JOB_STATUS_UNKNOWN"` - `"INDEX_JOB_STATUS_PARTIAL"` - `"INDEX_JOB_STATUS_IN_PROGRESS"` - `"INDEX_JOB_STATUS_COMPLETED"` - `"INDEX_JOB_STATUS_FAILED"` - `"INDEX_JOB_STATUS_NO_CHANGES"` - `"INDEX_JOB_STATUS_PENDING"` - `tokens?: number` Number of tokens - `total_datasources?: number` Number of datasources being indexed - `total_items_failed?: string` Total Items Failed - `total_items_indexed?: string` Total Items Indexed - `total_items_skipped?: string` Total Items Skipped - `updated_at?: string` Last modified - `uuid?: string` Unique id - `name?: string` Name of knowledge base - `project_id?: string` - `region?: string` Region code - `tags?: Array` Tags to organize related resources - `updated_at?: string` Last modified - `user_id?: string` Id of user that created the knowledge base - `uuid?: string` Unique id for knowledge base ### Example ```typescript import Gradient from '@digitalocean/gradient'; const client = new Gradient(); const knowledgeBase = await client.knowledgeBases.update('"123e4567-e89b-12d3-a456-426614174000"'); console.log(knowledgeBase.knowledge_base); ``` ## List `client.knowledgeBases.list(KnowledgeBaseListParamsquery?, RequestOptionsoptions?): KnowledgeBaseListResponse` **get** `/v2/gen-ai/knowledge_bases` To list all knowledge bases, send a GET request to `/v2/gen-ai/knowledge_bases`. ### Parameters - `query: KnowledgeBaseListParams` - `page?: number` Page number. - `per_page?: number` Items per page. ### Returns - `KnowledgeBaseListResponse` List of knowledge bases - `knowledge_bases?: Array` The knowledge bases - `added_to_agent_at?: string` Time when the knowledge base was added to the agent - `created_at?: string` Creation date / time - `database_id?: string` - `embedding_model_uuid?: string` - `is_public?: boolean` Whether the knowledge base is public or not - `last_indexing_job?: APIIndexingJob` IndexingJob description - `completed_datasources?: number` Number of datasources indexed completed - `created_at?: string` Creation date / time - `data_source_uuids?: Array` - `finished_at?: string` - `knowledge_base_uuid?: string` Knowledge base id - `phase?: "BATCH_JOB_PHASE_UNKNOWN" | "BATCH_JOB_PHASE_PENDING" | "BATCH_JOB_PHASE_RUNNING" | 4 more` - `"BATCH_JOB_PHASE_UNKNOWN"` - `"BATCH_JOB_PHASE_PENDING"` - `"BATCH_JOB_PHASE_RUNNING"` - `"BATCH_JOB_PHASE_SUCCEEDED"` - `"BATCH_JOB_PHASE_FAILED"` - `"BATCH_JOB_PHASE_ERROR"` - `"BATCH_JOB_PHASE_CANCELLED"` - `started_at?: string` - `status?: "INDEX_JOB_STATUS_UNKNOWN" | "INDEX_JOB_STATUS_PARTIAL" | "INDEX_JOB_STATUS_IN_PROGRESS" | 4 more` - `"INDEX_JOB_STATUS_UNKNOWN"` - `"INDEX_JOB_STATUS_PARTIAL"` - `"INDEX_JOB_STATUS_IN_PROGRESS"` - `"INDEX_JOB_STATUS_COMPLETED"` - `"INDEX_JOB_STATUS_FAILED"` - `"INDEX_JOB_STATUS_NO_CHANGES"` - `"INDEX_JOB_STATUS_PENDING"` - `tokens?: number` Number of tokens - `total_datasources?: number` Number of datasources being indexed - `total_items_failed?: string` Total Items Failed - `total_items_indexed?: string` Total Items Indexed - `total_items_skipped?: string` Total Items Skipped - `updated_at?: string` Last modified - `uuid?: string` Unique id - `name?: string` Name of knowledge base - `project_id?: string` - `region?: string` Region code - `tags?: Array` Tags to organize related resources - `updated_at?: string` Last modified - `user_id?: string` Id of user that created the knowledge base - `uuid?: string` Unique id for knowledge base - `links?: APILinks` Links to other pages - `pages?: Pages` Information about how to reach other pages - `first?: string` First page - `last?: string` Last page - `next?: string` Next page - `previous?: string` Previous page - `meta?: APIMeta` Meta information about the data set - `page?: number` The current page - `pages?: number` Total number of pages - `total?: number` Total amount of items over all pages ### Example ```typescript import Gradient from '@digitalocean/gradient'; const client = new Gradient(); const knowledgeBases = await client.knowledgeBases.list(); console.log(knowledgeBases.knowledge_bases); ``` ## Delete `client.knowledgeBases.delete(stringuuid, RequestOptionsoptions?): KnowledgeBaseDeleteResponse` **delete** `/v2/gen-ai/knowledge_bases/{uuid}` To delete a knowledge base, send a DELETE request to `/v2/gen-ai/knowledge_bases/{uuid}`. ### Parameters - `uuid: string` ### Returns - `KnowledgeBaseDeleteResponse` Information about a deleted knowledge base - `uuid?: string` The id of the deleted knowledge base ### Example ```typescript import Gradient from '@digitalocean/gradient'; const client = new Gradient(); const knowledgeBase = await client.knowledgeBases.delete('"123e4567-e89b-12d3-a456-426614174000"'); console.log(knowledgeBase.uuid); ``` ## Domain Types ### API Knowledge Base - `APIKnowledgeBase` Knowledgebase Description - `added_to_agent_at?: string` Time when the knowledge base was added to the agent - `created_at?: string` Creation date / time - `database_id?: string` - `embedding_model_uuid?: string` - `is_public?: boolean` Whether the knowledge base is public or not - `last_indexing_job?: APIIndexingJob` IndexingJob description - `completed_datasources?: number` Number of datasources indexed completed - `created_at?: string` Creation date / time - `data_source_uuids?: Array` - `finished_at?: string` - `knowledge_base_uuid?: string` Knowledge base id - `phase?: "BATCH_JOB_PHASE_UNKNOWN" | "BATCH_JOB_PHASE_PENDING" | "BATCH_JOB_PHASE_RUNNING" | 4 more` - `"BATCH_JOB_PHASE_UNKNOWN"` - `"BATCH_JOB_PHASE_PENDING"` - `"BATCH_JOB_PHASE_RUNNING"` - `"BATCH_JOB_PHASE_SUCCEEDED"` - `"BATCH_JOB_PHASE_FAILED"` - `"BATCH_JOB_PHASE_ERROR"` - `"BATCH_JOB_PHASE_CANCELLED"` - `started_at?: string` - `status?: "INDEX_JOB_STATUS_UNKNOWN" | "INDEX_JOB_STATUS_PARTIAL" | "INDEX_JOB_STATUS_IN_PROGRESS" | 4 more` - `"INDEX_JOB_STATUS_UNKNOWN"` - `"INDEX_JOB_STATUS_PARTIAL"` - `"INDEX_JOB_STATUS_IN_PROGRESS"` - `"INDEX_JOB_STATUS_COMPLETED"` - `"INDEX_JOB_STATUS_FAILED"` - `"INDEX_JOB_STATUS_NO_CHANGES"` - `"INDEX_JOB_STATUS_PENDING"` - `tokens?: number` Number of tokens - `total_datasources?: number` Number of datasources being indexed - `total_items_failed?: string` Total Items Failed - `total_items_indexed?: string` Total Items Indexed - `total_items_skipped?: string` Total Items Skipped - `updated_at?: string` Last modified - `uuid?: string` Unique id - `name?: string` Name of knowledge base - `project_id?: string` - `region?: string` Region code - `tags?: Array` Tags to organize related resources - `updated_at?: string` Last modified - `user_id?: string` Id of user that created the knowledge base - `uuid?: string` Unique id for knowledge base # Data Sources ## Create `client.knowledgeBases.dataSources.create(stringknowledgeBaseUuid, DataSourceCreateParamsbody?, RequestOptionsoptions?): DataSourceCreateResponse` **post** `/v2/gen-ai/knowledge_bases/{knowledge_base_uuid}/data_sources` To add a data source to a knowledge base, send a POST request to `/v2/gen-ai/knowledge_bases/{knowledge_base_uuid}/data_sources`. ### Parameters - `knowledgeBaseUuid: string` - `body: DataSourceCreateParams` - `aws_data_source?: AwsDataSource` AWS S3 Data Source - `bucket_name?: string` Spaces bucket name - `item_path?: string` - `key_id?: string` The AWS Key ID - `region?: string` Region of bucket - `secret_key?: string` The AWS Secret Key - `knowledge_base_uuid?: string` Knowledge base id - `spaces_data_source?: APISpacesDataSource` Spaces Bucket Data Source - `bucket_name?: string` Spaces bucket name - `item_path?: string` - `region?: string` Region of bucket - `web_crawler_data_source?: APIWebCrawlerDataSource` WebCrawlerDataSource - `base_url?: string` The base url to crawl. - `crawling_option?: "UNKNOWN" | "SCOPED" | "PATH" | 2 more` Options for specifying how URLs found on pages should be handled. - UNKNOWN: Default unknown value - SCOPED: Only include the base URL. - PATH: Crawl the base URL and linked pages within the URL path. - DOMAIN: Crawl the base URL and linked pages within the same domain. - SUBDOMAINS: Crawl the base URL and linked pages for any subdomain. - `"UNKNOWN"` - `"SCOPED"` - `"PATH"` - `"DOMAIN"` - `"SUBDOMAINS"` - `embed_media?: boolean` Whether to ingest and index media (images, etc.) on web pages. ### Returns - `DataSourceCreateResponse` Information about a newly created knowldege base data source - `knowledge_base_data_source?: APIKnowledgeBaseDataSource` Data Source configuration for Knowledge Bases - `aws_data_source?: AwsDataSource` AWS S3 Data Source for Display - `bucket_name?: string` Spaces bucket name - `item_path?: string` - `region?: string` Region of bucket - `bucket_name?: string` Name of storage bucket - Deprecated, moved to data_source_details - `created_at?: string` Creation date / time - `dropbox_data_source?: DropboxDataSource` Dropbox Data Source for Display - `folder?: string` - `file_upload_data_source?: APIFileUploadDataSource` File to upload as data source for knowledge base. - `original_file_name?: string` The original file name - `size_in_bytes?: string` The size of the file in bytes - `stored_object_key?: string` The object key the file was stored as - `item_path?: string` Path of folder or object in bucket - Deprecated, moved to data_source_details - `last_datasource_indexing_job?: APIIndexedDataSource` - `completed_at?: string` Timestamp when data source completed indexing - `data_source_uuid?: string` Uuid of the indexed data source - `error_details?: string` A detailed error description - `error_msg?: string` A string code provinding a hint which part of the system experienced an error - `failed_item_count?: string` Total count of files that have failed - `indexed_file_count?: string` Total count of files that have been indexed - `indexed_item_count?: string` Total count of files that have been indexed - `removed_item_count?: string` Total count of files that have been removed - `skipped_item_count?: string` Total count of files that have been skipped - `started_at?: string` Timestamp when data source started indexing - `status?: "DATA_SOURCE_STATUS_UNKNOWN" | "DATA_SOURCE_STATUS_IN_PROGRESS" | "DATA_SOURCE_STATUS_UPDATED" | 3 more` - `"DATA_SOURCE_STATUS_UNKNOWN"` - `"DATA_SOURCE_STATUS_IN_PROGRESS"` - `"DATA_SOURCE_STATUS_UPDATED"` - `"DATA_SOURCE_STATUS_PARTIALLY_UPDATED"` - `"DATA_SOURCE_STATUS_NOT_UPDATED"` - `"DATA_SOURCE_STATUS_FAILED"` - `total_bytes?: string` Total size of files in data source in bytes - `total_bytes_indexed?: string` Total size of files in data source in bytes that have been indexed - `total_file_count?: string` Total file count in the data source - `last_indexing_job?: APIIndexingJob` IndexingJob description - `completed_datasources?: number` Number of datasources indexed completed - `created_at?: string` Creation date / time - `data_source_uuids?: Array` - `finished_at?: string` - `knowledge_base_uuid?: string` Knowledge base id - `phase?: "BATCH_JOB_PHASE_UNKNOWN" | "BATCH_JOB_PHASE_PENDING" | "BATCH_JOB_PHASE_RUNNING" | 4 more` - `"BATCH_JOB_PHASE_UNKNOWN"` - `"BATCH_JOB_PHASE_PENDING"` - `"BATCH_JOB_PHASE_RUNNING"` - `"BATCH_JOB_PHASE_SUCCEEDED"` - `"BATCH_JOB_PHASE_FAILED"` - `"BATCH_JOB_PHASE_ERROR"` - `"BATCH_JOB_PHASE_CANCELLED"` - `started_at?: string` - `status?: "INDEX_JOB_STATUS_UNKNOWN" | "INDEX_JOB_STATUS_PARTIAL" | "INDEX_JOB_STATUS_IN_PROGRESS" | 4 more` - `"INDEX_JOB_STATUS_UNKNOWN"` - `"INDEX_JOB_STATUS_PARTIAL"` - `"INDEX_JOB_STATUS_IN_PROGRESS"` - `"INDEX_JOB_STATUS_COMPLETED"` - `"INDEX_JOB_STATUS_FAILED"` - `"INDEX_JOB_STATUS_NO_CHANGES"` - `"INDEX_JOB_STATUS_PENDING"` - `tokens?: number` Number of tokens - `total_datasources?: number` Number of datasources being indexed - `total_items_failed?: string` Total Items Failed - `total_items_indexed?: string` Total Items Indexed - `total_items_skipped?: string` Total Items Skipped - `updated_at?: string` Last modified - `uuid?: string` Unique id - `region?: string` Region code - Deprecated, moved to data_source_details - `spaces_data_source?: APISpacesDataSource` Spaces Bucket Data Source - `bucket_name?: string` Spaces bucket name - `item_path?: string` - `region?: string` Region of bucket - `updated_at?: string` Last modified - `uuid?: string` Unique id of knowledge base - `web_crawler_data_source?: APIWebCrawlerDataSource` WebCrawlerDataSource - `base_url?: string` The base url to crawl. - `crawling_option?: "UNKNOWN" | "SCOPED" | "PATH" | 2 more` Options for specifying how URLs found on pages should be handled. - UNKNOWN: Default unknown value - SCOPED: Only include the base URL. - PATH: Crawl the base URL and linked pages within the URL path. - DOMAIN: Crawl the base URL and linked pages within the same domain. - SUBDOMAINS: Crawl the base URL and linked pages for any subdomain. - `"UNKNOWN"` - `"SCOPED"` - `"PATH"` - `"DOMAIN"` - `"SUBDOMAINS"` - `embed_media?: boolean` Whether to ingest and index media (images, etc.) on web pages. ### Example ```typescript import Gradient from '@digitalocean/gradient'; const client = new Gradient(); const dataSource = await client.knowledgeBases.dataSources.create('"123e4567-e89b-12d3-a456-426614174000"'); console.log(dataSource.knowledge_base_data_source); ``` ## List `client.knowledgeBases.dataSources.list(stringknowledgeBaseUuid, DataSourceListParamsquery?, RequestOptionsoptions?): DataSourceListResponse` **get** `/v2/gen-ai/knowledge_bases/{knowledge_base_uuid}/data_sources` To list all data sources for a knowledge base, send a GET request to `/v2/gen-ai/knowledge_bases/{knowledge_base_uuid}/data_sources`. ### Parameters - `knowledgeBaseUuid: string` - `query: DataSourceListParams` - `page?: number` Page number. - `per_page?: number` Items per page. ### Returns - `DataSourceListResponse` A list of knowledge base data sources - `knowledge_base_data_sources?: Array` The data sources - `aws_data_source?: AwsDataSource` AWS S3 Data Source for Display - `bucket_name?: string` Spaces bucket name - `item_path?: string` - `region?: string` Region of bucket - `bucket_name?: string` Name of storage bucket - Deprecated, moved to data_source_details - `created_at?: string` Creation date / time - `dropbox_data_source?: DropboxDataSource` Dropbox Data Source for Display - `folder?: string` - `file_upload_data_source?: APIFileUploadDataSource` File to upload as data source for knowledge base. - `original_file_name?: string` The original file name - `size_in_bytes?: string` The size of the file in bytes - `stored_object_key?: string` The object key the file was stored as - `item_path?: string` Path of folder or object in bucket - Deprecated, moved to data_source_details - `last_datasource_indexing_job?: APIIndexedDataSource` - `completed_at?: string` Timestamp when data source completed indexing - `data_source_uuid?: string` Uuid of the indexed data source - `error_details?: string` A detailed error description - `error_msg?: string` A string code provinding a hint which part of the system experienced an error - `failed_item_count?: string` Total count of files that have failed - `indexed_file_count?: string` Total count of files that have been indexed - `indexed_item_count?: string` Total count of files that have been indexed - `removed_item_count?: string` Total count of files that have been removed - `skipped_item_count?: string` Total count of files that have been skipped - `started_at?: string` Timestamp when data source started indexing - `status?: "DATA_SOURCE_STATUS_UNKNOWN" | "DATA_SOURCE_STATUS_IN_PROGRESS" | "DATA_SOURCE_STATUS_UPDATED" | 3 more` - `"DATA_SOURCE_STATUS_UNKNOWN"` - `"DATA_SOURCE_STATUS_IN_PROGRESS"` - `"DATA_SOURCE_STATUS_UPDATED"` - `"DATA_SOURCE_STATUS_PARTIALLY_UPDATED"` - `"DATA_SOURCE_STATUS_NOT_UPDATED"` - `"DATA_SOURCE_STATUS_FAILED"` - `total_bytes?: string` Total size of files in data source in bytes - `total_bytes_indexed?: string` Total size of files in data source in bytes that have been indexed - `total_file_count?: string` Total file count in the data source - `last_indexing_job?: APIIndexingJob` IndexingJob description - `completed_datasources?: number` Number of datasources indexed completed - `created_at?: string` Creation date / time - `data_source_uuids?: Array` - `finished_at?: string` - `knowledge_base_uuid?: string` Knowledge base id - `phase?: "BATCH_JOB_PHASE_UNKNOWN" | "BATCH_JOB_PHASE_PENDING" | "BATCH_JOB_PHASE_RUNNING" | 4 more` - `"BATCH_JOB_PHASE_UNKNOWN"` - `"BATCH_JOB_PHASE_PENDING"` - `"BATCH_JOB_PHASE_RUNNING"` - `"BATCH_JOB_PHASE_SUCCEEDED"` - `"BATCH_JOB_PHASE_FAILED"` - `"BATCH_JOB_PHASE_ERROR"` - `"BATCH_JOB_PHASE_CANCELLED"` - `started_at?: string` - `status?: "INDEX_JOB_STATUS_UNKNOWN" | "INDEX_JOB_STATUS_PARTIAL" | "INDEX_JOB_STATUS_IN_PROGRESS" | 4 more` - `"INDEX_JOB_STATUS_UNKNOWN"` - `"INDEX_JOB_STATUS_PARTIAL"` - `"INDEX_JOB_STATUS_IN_PROGRESS"` - `"INDEX_JOB_STATUS_COMPLETED"` - `"INDEX_JOB_STATUS_FAILED"` - `"INDEX_JOB_STATUS_NO_CHANGES"` - `"INDEX_JOB_STATUS_PENDING"` - `tokens?: number` Number of tokens - `total_datasources?: number` Number of datasources being indexed - `total_items_failed?: string` Total Items Failed - `total_items_indexed?: string` Total Items Indexed - `total_items_skipped?: string` Total Items Skipped - `updated_at?: string` Last modified - `uuid?: string` Unique id - `region?: string` Region code - Deprecated, moved to data_source_details - `spaces_data_source?: APISpacesDataSource` Spaces Bucket Data Source - `bucket_name?: string` Spaces bucket name - `item_path?: string` - `region?: string` Region of bucket - `updated_at?: string` Last modified - `uuid?: string` Unique id of knowledge base - `web_crawler_data_source?: APIWebCrawlerDataSource` WebCrawlerDataSource - `base_url?: string` The base url to crawl. - `crawling_option?: "UNKNOWN" | "SCOPED" | "PATH" | 2 more` Options for specifying how URLs found on pages should be handled. - UNKNOWN: Default unknown value - SCOPED: Only include the base URL. - PATH: Crawl the base URL and linked pages within the URL path. - DOMAIN: Crawl the base URL and linked pages within the same domain. - SUBDOMAINS: Crawl the base URL and linked pages for any subdomain. - `"UNKNOWN"` - `"SCOPED"` - `"PATH"` - `"DOMAIN"` - `"SUBDOMAINS"` - `embed_media?: boolean` Whether to ingest and index media (images, etc.) on web pages. - `links?: APILinks` Links to other pages - `pages?: Pages` Information about how to reach other pages - `first?: string` First page - `last?: string` Last page - `next?: string` Next page - `previous?: string` Previous page - `meta?: APIMeta` Meta information about the data set - `page?: number` The current page - `pages?: number` Total number of pages - `total?: number` Total amount of items over all pages ### Example ```typescript import Gradient from '@digitalocean/gradient'; const client = new Gradient(); const dataSources = await client.knowledgeBases.dataSources.list('"123e4567-e89b-12d3-a456-426614174000"'); console.log(dataSources.knowledge_base_data_sources); ``` ## Delete `client.knowledgeBases.dataSources.delete(stringdataSourceUuid, DataSourceDeleteParamsparams, RequestOptionsoptions?): DataSourceDeleteResponse` **delete** `/v2/gen-ai/knowledge_bases/{knowledge_base_uuid}/data_sources/{data_source_uuid}` To delete a data source from a knowledge base, send a DELETE request to `/v2/gen-ai/knowledge_bases/{knowledge_base_uuid}/data_sources/{data_source_uuid}`. ### Parameters - `dataSourceUuid: string` - `params: DataSourceDeleteParams` - `knowledge_base_uuid: string` Knowledge base id ### Returns - `DataSourceDeleteResponse` Information about a newly deleted knowledge base data source - `data_source_uuid?: string` Data source id - `knowledge_base_uuid?: string` Knowledge base id ### Example ```typescript import Gradient from '@digitalocean/gradient'; const client = new Gradient(); const dataSource = await client.knowledgeBases.dataSources.delete('"123e4567-e89b-12d3-a456-426614174000"', { knowledge_base_uuid: '"123e4567-e89b-12d3-a456-426614174000"', }); console.log(dataSource.data_source_uuid); ``` ## Create Presigned URLs `client.knowledgeBases.dataSources.createPresignedURLs(DataSourceCreatePresignedURLsParamsbody?, RequestOptionsoptions?): DataSourceCreatePresignedURLsResponse` **post** `/v2/gen-ai/knowledge_bases/data_sources/file_upload_presigned_urls` To create presigned URLs for knowledge base data source file upload, send a POST request to `/v2/gen-ai/knowledge_bases/data_sources/file_upload_presigned_urls`. ### Parameters - `body: DataSourceCreatePresignedURLsParams` - `files?: Array` A list of files to generate presigned URLs for. - `file_name?: string` Local filename - `file_size?: string` The size of the file in bytes. ### Returns - `DataSourceCreatePresignedURLsResponse` Response with pre-signed urls to upload files. - `request_id?: string` The ID generated for the request for Presigned URLs. - `uploads?: Array` A list of generated presigned URLs and object keys, one per file. - `expires_at?: string` The time the url expires at. - `object_key?: string` The unique object key to store the file as. - `original_file_name?: string` The original file name. - `presigned_url?: string` The actual presigned URL the client can use to upload the file directly. ### Example ```typescript import Gradient from '@digitalocean/gradient'; const client = new Gradient(); const response = await client.knowledgeBases.dataSources.createPresignedURLs(); console.log(response.request_id); ``` ## Domain Types ### API File Upload Data Source - `APIFileUploadDataSource` File to upload as data source for knowledge base. - `original_file_name?: string` The original file name - `size_in_bytes?: string` The size of the file in bytes - `stored_object_key?: string` The object key the file was stored as ### API Knowledge Base Data Source - `APIKnowledgeBaseDataSource` Data Source configuration for Knowledge Bases - `aws_data_source?: AwsDataSource` AWS S3 Data Source for Display - `bucket_name?: string` Spaces bucket name - `item_path?: string` - `region?: string` Region of bucket - `bucket_name?: string` Name of storage bucket - Deprecated, moved to data_source_details - `created_at?: string` Creation date / time - `dropbox_data_source?: DropboxDataSource` Dropbox Data Source for Display - `folder?: string` - `file_upload_data_source?: APIFileUploadDataSource` File to upload as data source for knowledge base. - `original_file_name?: string` The original file name - `size_in_bytes?: string` The size of the file in bytes - `stored_object_key?: string` The object key the file was stored as - `item_path?: string` Path of folder or object in bucket - Deprecated, moved to data_source_details - `last_datasource_indexing_job?: APIIndexedDataSource` - `completed_at?: string` Timestamp when data source completed indexing - `data_source_uuid?: string` Uuid of the indexed data source - `error_details?: string` A detailed error description - `error_msg?: string` A string code provinding a hint which part of the system experienced an error - `failed_item_count?: string` Total count of files that have failed - `indexed_file_count?: string` Total count of files that have been indexed - `indexed_item_count?: string` Total count of files that have been indexed - `removed_item_count?: string` Total count of files that have been removed - `skipped_item_count?: string` Total count of files that have been skipped - `started_at?: string` Timestamp when data source started indexing - `status?: "DATA_SOURCE_STATUS_UNKNOWN" | "DATA_SOURCE_STATUS_IN_PROGRESS" | "DATA_SOURCE_STATUS_UPDATED" | 3 more` - `"DATA_SOURCE_STATUS_UNKNOWN"` - `"DATA_SOURCE_STATUS_IN_PROGRESS"` - `"DATA_SOURCE_STATUS_UPDATED"` - `"DATA_SOURCE_STATUS_PARTIALLY_UPDATED"` - `"DATA_SOURCE_STATUS_NOT_UPDATED"` - `"DATA_SOURCE_STATUS_FAILED"` - `total_bytes?: string` Total size of files in data source in bytes - `total_bytes_indexed?: string` Total size of files in data source in bytes that have been indexed - `total_file_count?: string` Total file count in the data source - `last_indexing_job?: APIIndexingJob` IndexingJob description - `completed_datasources?: number` Number of datasources indexed completed - `created_at?: string` Creation date / time - `data_source_uuids?: Array` - `finished_at?: string` - `knowledge_base_uuid?: string` Knowledge base id - `phase?: "BATCH_JOB_PHASE_UNKNOWN" | "BATCH_JOB_PHASE_PENDING" | "BATCH_JOB_PHASE_RUNNING" | 4 more` - `"BATCH_JOB_PHASE_UNKNOWN"` - `"BATCH_JOB_PHASE_PENDING"` - `"BATCH_JOB_PHASE_RUNNING"` - `"BATCH_JOB_PHASE_SUCCEEDED"` - `"BATCH_JOB_PHASE_FAILED"` - `"BATCH_JOB_PHASE_ERROR"` - `"BATCH_JOB_PHASE_CANCELLED"` - `started_at?: string` - `status?: "INDEX_JOB_STATUS_UNKNOWN" | "INDEX_JOB_STATUS_PARTIAL" | "INDEX_JOB_STATUS_IN_PROGRESS" | 4 more` - `"INDEX_JOB_STATUS_UNKNOWN"` - `"INDEX_JOB_STATUS_PARTIAL"` - `"INDEX_JOB_STATUS_IN_PROGRESS"` - `"INDEX_JOB_STATUS_COMPLETED"` - `"INDEX_JOB_STATUS_FAILED"` - `"INDEX_JOB_STATUS_NO_CHANGES"` - `"INDEX_JOB_STATUS_PENDING"` - `tokens?: number` Number of tokens - `total_datasources?: number` Number of datasources being indexed - `total_items_failed?: string` Total Items Failed - `total_items_indexed?: string` Total Items Indexed - `total_items_skipped?: string` Total Items Skipped - `updated_at?: string` Last modified - `uuid?: string` Unique id - `region?: string` Region code - Deprecated, moved to data_source_details - `spaces_data_source?: APISpacesDataSource` Spaces Bucket Data Source - `bucket_name?: string` Spaces bucket name - `item_path?: string` - `region?: string` Region of bucket - `updated_at?: string` Last modified - `uuid?: string` Unique id of knowledge base - `web_crawler_data_source?: APIWebCrawlerDataSource` WebCrawlerDataSource - `base_url?: string` The base url to crawl. - `crawling_option?: "UNKNOWN" | "SCOPED" | "PATH" | 2 more` Options for specifying how URLs found on pages should be handled. - UNKNOWN: Default unknown value - SCOPED: Only include the base URL. - PATH: Crawl the base URL and linked pages within the URL path. - DOMAIN: Crawl the base URL and linked pages within the same domain. - SUBDOMAINS: Crawl the base URL and linked pages for any subdomain. - `"UNKNOWN"` - `"SCOPED"` - `"PATH"` - `"DOMAIN"` - `"SUBDOMAINS"` - `embed_media?: boolean` Whether to ingest and index media (images, etc.) on web pages. ### API Spaces Data Source - `APISpacesDataSource` Spaces Bucket Data Source - `bucket_name?: string` Spaces bucket name - `item_path?: string` - `region?: string` Region of bucket ### API Web Crawler Data Source - `APIWebCrawlerDataSource` WebCrawlerDataSource - `base_url?: string` The base url to crawl. - `crawling_option?: "UNKNOWN" | "SCOPED" | "PATH" | 2 more` Options for specifying how URLs found on pages should be handled. - UNKNOWN: Default unknown value - SCOPED: Only include the base URL. - PATH: Crawl the base URL and linked pages within the URL path. - DOMAIN: Crawl the base URL and linked pages within the same domain. - SUBDOMAINS: Crawl the base URL and linked pages for any subdomain. - `"UNKNOWN"` - `"SCOPED"` - `"PATH"` - `"DOMAIN"` - `"SUBDOMAINS"` - `embed_media?: boolean` Whether to ingest and index media (images, etc.) on web pages. ### Aws Data Source - `AwsDataSource` AWS S3 Data Source - `bucket_name?: string` Spaces bucket name - `item_path?: string` - `key_id?: string` The AWS Key ID - `region?: string` Region of bucket - `secret_key?: string` The AWS Secret Key # Indexing Jobs ## Create `client.knowledgeBases.indexingJobs.create(IndexingJobCreateParamsbody?, RequestOptionsoptions?): IndexingJobCreateResponse` **post** `/v2/gen-ai/indexing_jobs` To start an indexing job for a knowledge base, send a POST request to `/v2/gen-ai/indexing_jobs`. ### Parameters - `body: IndexingJobCreateParams` - `data_source_uuids?: Array` List of data source ids to index, if none are provided, all data sources will be indexed - `knowledge_base_uuid?: string` Knowledge base id ### Returns - `IndexingJobCreateResponse` StartKnowledgeBaseIndexingJobOutput description - `job?: APIIndexingJob` IndexingJob description - `completed_datasources?: number` Number of datasources indexed completed - `created_at?: string` Creation date / time - `data_source_uuids?: Array` - `finished_at?: string` - `knowledge_base_uuid?: string` Knowledge base id - `phase?: "BATCH_JOB_PHASE_UNKNOWN" | "BATCH_JOB_PHASE_PENDING" | "BATCH_JOB_PHASE_RUNNING" | 4 more` - `"BATCH_JOB_PHASE_UNKNOWN"` - `"BATCH_JOB_PHASE_PENDING"` - `"BATCH_JOB_PHASE_RUNNING"` - `"BATCH_JOB_PHASE_SUCCEEDED"` - `"BATCH_JOB_PHASE_FAILED"` - `"BATCH_JOB_PHASE_ERROR"` - `"BATCH_JOB_PHASE_CANCELLED"` - `started_at?: string` - `status?: "INDEX_JOB_STATUS_UNKNOWN" | "INDEX_JOB_STATUS_PARTIAL" | "INDEX_JOB_STATUS_IN_PROGRESS" | 4 more` - `"INDEX_JOB_STATUS_UNKNOWN"` - `"INDEX_JOB_STATUS_PARTIAL"` - `"INDEX_JOB_STATUS_IN_PROGRESS"` - `"INDEX_JOB_STATUS_COMPLETED"` - `"INDEX_JOB_STATUS_FAILED"` - `"INDEX_JOB_STATUS_NO_CHANGES"` - `"INDEX_JOB_STATUS_PENDING"` - `tokens?: number` Number of tokens - `total_datasources?: number` Number of datasources being indexed - `total_items_failed?: string` Total Items Failed - `total_items_indexed?: string` Total Items Indexed - `total_items_skipped?: string` Total Items Skipped - `updated_at?: string` Last modified - `uuid?: string` Unique id ### Example ```typescript import Gradient from '@digitalocean/gradient'; const client = new Gradient(); const indexingJob = await client.knowledgeBases.indexingJobs.create(); console.log(indexingJob.job); ``` ## Retrieve `client.knowledgeBases.indexingJobs.retrieve(stringuuid, RequestOptionsoptions?): IndexingJobRetrieveResponse` **get** `/v2/gen-ai/indexing_jobs/{uuid}` To get status of an indexing Job for a knowledge base, send a GET request to `/v2/gen-ai/indexing_jobs/{uuid}`. ### Parameters - `uuid: string` ### Returns - `IndexingJobRetrieveResponse` GetKnowledgeBaseIndexingJobOutput description - `job?: APIIndexingJob` IndexingJob description - `completed_datasources?: number` Number of datasources indexed completed - `created_at?: string` Creation date / time - `data_source_uuids?: Array` - `finished_at?: string` - `knowledge_base_uuid?: string` Knowledge base id - `phase?: "BATCH_JOB_PHASE_UNKNOWN" | "BATCH_JOB_PHASE_PENDING" | "BATCH_JOB_PHASE_RUNNING" | 4 more` - `"BATCH_JOB_PHASE_UNKNOWN"` - `"BATCH_JOB_PHASE_PENDING"` - `"BATCH_JOB_PHASE_RUNNING"` - `"BATCH_JOB_PHASE_SUCCEEDED"` - `"BATCH_JOB_PHASE_FAILED"` - `"BATCH_JOB_PHASE_ERROR"` - `"BATCH_JOB_PHASE_CANCELLED"` - `started_at?: string` - `status?: "INDEX_JOB_STATUS_UNKNOWN" | "INDEX_JOB_STATUS_PARTIAL" | "INDEX_JOB_STATUS_IN_PROGRESS" | 4 more` - `"INDEX_JOB_STATUS_UNKNOWN"` - `"INDEX_JOB_STATUS_PARTIAL"` - `"INDEX_JOB_STATUS_IN_PROGRESS"` - `"INDEX_JOB_STATUS_COMPLETED"` - `"INDEX_JOB_STATUS_FAILED"` - `"INDEX_JOB_STATUS_NO_CHANGES"` - `"INDEX_JOB_STATUS_PENDING"` - `tokens?: number` Number of tokens - `total_datasources?: number` Number of datasources being indexed - `total_items_failed?: string` Total Items Failed - `total_items_indexed?: string` Total Items Indexed - `total_items_skipped?: string` Total Items Skipped - `updated_at?: string` Last modified - `uuid?: string` Unique id ### Example ```typescript import Gradient from '@digitalocean/gradient'; const client = new Gradient(); const indexingJob = await client.knowledgeBases.indexingJobs.retrieve( '"123e4567-e89b-12d3-a456-426614174000"', ); console.log(indexingJob.job); ``` ## List `client.knowledgeBases.indexingJobs.list(IndexingJobListParamsquery?, RequestOptionsoptions?): IndexingJobListResponse` **get** `/v2/gen-ai/indexing_jobs` To list all indexing jobs for a knowledge base, send a GET request to `/v2/gen-ai/indexing_jobs`. ### Parameters - `query: IndexingJobListParams` - `page?: number` Page number. - `per_page?: number` Items per page. ### Returns - `IndexingJobListResponse` Indexing jobs - `jobs?: Array` The indexing jobs - `completed_datasources?: number` Number of datasources indexed completed - `created_at?: string` Creation date / time - `data_source_uuids?: Array` - `finished_at?: string` - `knowledge_base_uuid?: string` Knowledge base id - `phase?: "BATCH_JOB_PHASE_UNKNOWN" | "BATCH_JOB_PHASE_PENDING" | "BATCH_JOB_PHASE_RUNNING" | 4 more` - `"BATCH_JOB_PHASE_UNKNOWN"` - `"BATCH_JOB_PHASE_PENDING"` - `"BATCH_JOB_PHASE_RUNNING"` - `"BATCH_JOB_PHASE_SUCCEEDED"` - `"BATCH_JOB_PHASE_FAILED"` - `"BATCH_JOB_PHASE_ERROR"` - `"BATCH_JOB_PHASE_CANCELLED"` - `started_at?: string` - `status?: "INDEX_JOB_STATUS_UNKNOWN" | "INDEX_JOB_STATUS_PARTIAL" | "INDEX_JOB_STATUS_IN_PROGRESS" | 4 more` - `"INDEX_JOB_STATUS_UNKNOWN"` - `"INDEX_JOB_STATUS_PARTIAL"` - `"INDEX_JOB_STATUS_IN_PROGRESS"` - `"INDEX_JOB_STATUS_COMPLETED"` - `"INDEX_JOB_STATUS_FAILED"` - `"INDEX_JOB_STATUS_NO_CHANGES"` - `"INDEX_JOB_STATUS_PENDING"` - `tokens?: number` Number of tokens - `total_datasources?: number` Number of datasources being indexed - `total_items_failed?: string` Total Items Failed - `total_items_indexed?: string` Total Items Indexed - `total_items_skipped?: string` Total Items Skipped - `updated_at?: string` Last modified - `uuid?: string` Unique id - `links?: APILinks` Links to other pages - `pages?: Pages` Information about how to reach other pages - `first?: string` First page - `last?: string` Last page - `next?: string` Next page - `previous?: string` Previous page - `meta?: APIMeta` Meta information about the data set - `page?: number` The current page - `pages?: number` Total number of pages - `total?: number` Total amount of items over all pages ### Example ```typescript import Gradient from '@digitalocean/gradient'; const client = new Gradient(); const indexingJobs = await client.knowledgeBases.indexingJobs.list(); console.log(indexingJobs.jobs); ``` ## Retrieve Data Sources `client.knowledgeBases.indexingJobs.retrieveDataSources(stringindexingJobUuid, RequestOptionsoptions?): IndexingJobRetrieveDataSourcesResponse` **get** `/v2/gen-ai/indexing_jobs/{indexing_job_uuid}/data_sources` To list all datasources for an indexing job, send a GET request to `/v2/gen-ai/indexing_jobs/{indexing_job_uuid}/data_sources`. ### Parameters - `indexingJobUuid: string` ### Returns - `IndexingJobRetrieveDataSourcesResponse` - `indexed_data_sources?: Array` - `completed_at?: string` Timestamp when data source completed indexing - `data_source_uuid?: string` Uuid of the indexed data source - `error_details?: string` A detailed error description - `error_msg?: string` A string code provinding a hint which part of the system experienced an error - `failed_item_count?: string` Total count of files that have failed - `indexed_file_count?: string` Total count of files that have been indexed - `indexed_item_count?: string` Total count of files that have been indexed - `removed_item_count?: string` Total count of files that have been removed - `skipped_item_count?: string` Total count of files that have been skipped - `started_at?: string` Timestamp when data source started indexing - `status?: "DATA_SOURCE_STATUS_UNKNOWN" | "DATA_SOURCE_STATUS_IN_PROGRESS" | "DATA_SOURCE_STATUS_UPDATED" | 3 more` - `"DATA_SOURCE_STATUS_UNKNOWN"` - `"DATA_SOURCE_STATUS_IN_PROGRESS"` - `"DATA_SOURCE_STATUS_UPDATED"` - `"DATA_SOURCE_STATUS_PARTIALLY_UPDATED"` - `"DATA_SOURCE_STATUS_NOT_UPDATED"` - `"DATA_SOURCE_STATUS_FAILED"` - `total_bytes?: string` Total size of files in data source in bytes - `total_bytes_indexed?: string` Total size of files in data source in bytes that have been indexed - `total_file_count?: string` Total file count in the data source ### Example ```typescript import Gradient from '@digitalocean/gradient'; const client = new Gradient(); const response = await client.knowledgeBases.indexingJobs.retrieveDataSources( '"123e4567-e89b-12d3-a456-426614174000"', ); console.log(response.indexed_data_sources); ``` ## Update Cancel `client.knowledgeBases.indexingJobs.updateCancel(stringpathUuid, IndexingJobUpdateCancelParamsbody?, RequestOptionsoptions?): IndexingJobUpdateCancelResponse` **put** `/v2/gen-ai/indexing_jobs/{uuid}/cancel` To cancel an indexing job for a knowledge base, send a PUT request to `/v2/gen-ai/indexing_jobs/{uuid}/cancel`. ### Parameters - `pathUuid: string` - `body: IndexingJobUpdateCancelParams` - `body_uuid?: string` A unique identifier for an indexing job. ### Returns - `IndexingJobUpdateCancelResponse` CancelKnowledgeBaseIndexingJobOutput description - `job?: APIIndexingJob` IndexingJob description - `completed_datasources?: number` Number of datasources indexed completed - `created_at?: string` Creation date / time - `data_source_uuids?: Array` - `finished_at?: string` - `knowledge_base_uuid?: string` Knowledge base id - `phase?: "BATCH_JOB_PHASE_UNKNOWN" | "BATCH_JOB_PHASE_PENDING" | "BATCH_JOB_PHASE_RUNNING" | 4 more` - `"BATCH_JOB_PHASE_UNKNOWN"` - `"BATCH_JOB_PHASE_PENDING"` - `"BATCH_JOB_PHASE_RUNNING"` - `"BATCH_JOB_PHASE_SUCCEEDED"` - `"BATCH_JOB_PHASE_FAILED"` - `"BATCH_JOB_PHASE_ERROR"` - `"BATCH_JOB_PHASE_CANCELLED"` - `started_at?: string` - `status?: "INDEX_JOB_STATUS_UNKNOWN" | "INDEX_JOB_STATUS_PARTIAL" | "INDEX_JOB_STATUS_IN_PROGRESS" | 4 more` - `"INDEX_JOB_STATUS_UNKNOWN"` - `"INDEX_JOB_STATUS_PARTIAL"` - `"INDEX_JOB_STATUS_IN_PROGRESS"` - `"INDEX_JOB_STATUS_COMPLETED"` - `"INDEX_JOB_STATUS_FAILED"` - `"INDEX_JOB_STATUS_NO_CHANGES"` - `"INDEX_JOB_STATUS_PENDING"` - `tokens?: number` Number of tokens - `total_datasources?: number` Number of datasources being indexed - `total_items_failed?: string` Total Items Failed - `total_items_indexed?: string` Total Items Indexed - `total_items_skipped?: string` Total Items Skipped - `updated_at?: string` Last modified - `uuid?: string` Unique id ### Example ```typescript import Gradient from '@digitalocean/gradient'; const client = new Gradient(); const response = await client.knowledgeBases.indexingJobs.updateCancel( '"123e4567-e89b-12d3-a456-426614174000"', ); console.log(response.job); ``` ## Domain Types ### API Indexed Data Source - `APIIndexedDataSource` - `completed_at?: string` Timestamp when data source completed indexing - `data_source_uuid?: string` Uuid of the indexed data source - `error_details?: string` A detailed error description - `error_msg?: string` A string code provinding a hint which part of the system experienced an error - `failed_item_count?: string` Total count of files that have failed - `indexed_file_count?: string` Total count of files that have been indexed - `indexed_item_count?: string` Total count of files that have been indexed - `removed_item_count?: string` Total count of files that have been removed - `skipped_item_count?: string` Total count of files that have been skipped - `started_at?: string` Timestamp when data source started indexing - `status?: "DATA_SOURCE_STATUS_UNKNOWN" | "DATA_SOURCE_STATUS_IN_PROGRESS" | "DATA_SOURCE_STATUS_UPDATED" | 3 more` - `"DATA_SOURCE_STATUS_UNKNOWN"` - `"DATA_SOURCE_STATUS_IN_PROGRESS"` - `"DATA_SOURCE_STATUS_UPDATED"` - `"DATA_SOURCE_STATUS_PARTIALLY_UPDATED"` - `"DATA_SOURCE_STATUS_NOT_UPDATED"` - `"DATA_SOURCE_STATUS_FAILED"` - `total_bytes?: string` Total size of files in data source in bytes - `total_bytes_indexed?: string` Total size of files in data source in bytes that have been indexed - `total_file_count?: string` Total file count in the data source ### API Indexing Job - `APIIndexingJob` IndexingJob description - `completed_datasources?: number` Number of datasources indexed completed - `created_at?: string` Creation date / time - `data_source_uuids?: Array` - `finished_at?: string` - `knowledge_base_uuid?: string` Knowledge base id - `phase?: "BATCH_JOB_PHASE_UNKNOWN" | "BATCH_JOB_PHASE_PENDING" | "BATCH_JOB_PHASE_RUNNING" | 4 more` - `"BATCH_JOB_PHASE_UNKNOWN"` - `"BATCH_JOB_PHASE_PENDING"` - `"BATCH_JOB_PHASE_RUNNING"` - `"BATCH_JOB_PHASE_SUCCEEDED"` - `"BATCH_JOB_PHASE_FAILED"` - `"BATCH_JOB_PHASE_ERROR"` - `"BATCH_JOB_PHASE_CANCELLED"` - `started_at?: string` - `status?: "INDEX_JOB_STATUS_UNKNOWN" | "INDEX_JOB_STATUS_PARTIAL" | "INDEX_JOB_STATUS_IN_PROGRESS" | 4 more` - `"INDEX_JOB_STATUS_UNKNOWN"` - `"INDEX_JOB_STATUS_PARTIAL"` - `"INDEX_JOB_STATUS_IN_PROGRESS"` - `"INDEX_JOB_STATUS_COMPLETED"` - `"INDEX_JOB_STATUS_FAILED"` - `"INDEX_JOB_STATUS_NO_CHANGES"` - `"INDEX_JOB_STATUS_PENDING"` - `tokens?: number` Number of tokens - `total_datasources?: number` Number of datasources being indexed - `total_items_failed?: string` Total Items Failed - `total_items_indexed?: string` Total Items Indexed - `total_items_skipped?: string` Total Items Skipped - `updated_at?: string` Last modified - `uuid?: string` Unique id