# Knowledge Bases ## Create `knowledge_bases.create(KnowledgeBaseCreateParams**kwargs) -> KnowledgeBaseCreateResponse` **post** `/v2/gen-ai/knowledge_bases` To create a knowledge base, send a POST request to `/v2/gen-ai/knowledge_bases`. ### Parameters - **database\_id:** `str` 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:** `Iterable[Datasource]` 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:** `AwsDataSourceParam` AWS S3 Data Source - **bucket\_name:** `str` Deprecated, moved to data_source_details - **bucket\_region:** `str` Deprecated, moved to data_source_details - **file\_upload\_data\_source:** `APIFileUploadDataSourceParam` File to upload as data source for knowledge base. - **item\_path:** `str` - **spaces\_data\_source:** `APISpacesDataSourceParam` Spaces Bucket Data Source - **web\_crawler\_data\_source:** `APIWebCrawlerDataSourceParam` WebCrawlerDataSource - **embedding\_model\_uuid:** `str` Identifier for the [embedding model](https://docs.digitalocean.com/products/genai-platform/details/models/#embedding-models). - **name:** `str` Name of the knowledge base. - **project\_id:** `str` Identifier of the DigitalOcean project this knowledge base will belong to. - **region:** `str` The datacenter region to deploy the knowledge base in. - **tags:** `List[str]` Tags to organize your knowledge base. - **vpc\_uuid:** `str` The VPC to deploy the knowledge base database in ### Returns - `class KnowledgeBaseCreateResponse` Information about a newly created knowledge base - **knowledge\_base:** `Optional[APIKnowledgeBase]` Knowledgebase Description ### Example ```python from do_gradientai import GradientAI client = GradientAI() knowledge_base = client.knowledge_bases.create() print(knowledge_base.knowledge_base) ``` ## Retrieve `knowledge_bases.retrieve(struuid) -> 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:** `str` ### Returns - `class KnowledgeBaseRetrieveResponse` The knowledge base - **database\_status:** `Optional[Literal["CREATING", "ONLINE", "POWEROFF", 9 more]]` - `"CREATING"` - `"ONLINE"` - `"POWEROFF"` - `"REBUILDING"` - `"REBALANCING"` - `"DECOMMISSIONED"` - `"FORKING"` - `"MIGRATING"` - `"RESIZING"` - `"RESTORING"` - `"POWERING_ON"` - `"UNHEALTHY"` - **knowledge\_base:** `Optional[APIKnowledgeBase]` Knowledgebase Description ### Example ```python from do_gradientai import GradientAI client = GradientAI() knowledge_base = client.knowledge_bases.retrieve( "uuid", ) print(knowledge_base.database_status) ``` ## Update `knowledge_bases.update(strpath_uuid, KnowledgeBaseUpdateParams**kwargs) -> 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 - **uuid:** `str` - **database\_id:** `str` The id of the DigitalOcean database this knowledge base will use, optiona. - **embedding\_model\_uuid:** `str` Identifier for the foundation model. - **name:** `str` Knowledge base name - **project\_id:** `str` The id of the DigitalOcean project this knowledge base will belong to - **tags:** `List[str]` Tags to organize your knowledge base. - **uuid:** `str` ### Returns - `class KnowledgeBaseUpdateResponse` Information about an updated knowledge base - **knowledge\_base:** `Optional[APIKnowledgeBase]` Knowledgebase Description ### Example ```python from do_gradientai import GradientAI client = GradientAI() knowledge_base = client.knowledge_bases.update( path_uuid="\"123e4567-e89b-12d3-a456-426614174000\"", ) print(knowledge_base.knowledge_base) ``` ## List `knowledge_bases.list(KnowledgeBaseListParams**kwargs) -> KnowledgeBaseListResponse` **get** `/v2/gen-ai/knowledge_bases` To list all knowledge bases, send a GET request to `/v2/gen-ai/knowledge_bases`. ### Parameters - **page:** `int` Page number. - **per\_page:** `int` Items per page. ### Returns - `class KnowledgeBaseListResponse` List of knowledge bases - **knowledge\_bases:** `Optional[List[APIKnowledgeBase]]` The knowledge bases - **added\_to\_agent\_at:** `Optional[datetime]` Time when the knowledge base was added to the agent - **created\_at:** `Optional[datetime]` Creation date / time - **database\_id:** `Optional[str]` - **embedding\_model\_uuid:** `Optional[str]` - **is\_public:** `Optional[bool]` Whether the knowledge base is public or not - **last\_indexing\_job:** `Optional[APIIndexingJob]` IndexingJob description - **name:** `Optional[str]` Name of knowledge base - **project\_id:** `Optional[str]` - **region:** `Optional[str]` Region code - **tags:** `Optional[List[str]]` Tags to organize related resources - **updated\_at:** `Optional[datetime]` Last modified - **user\_id:** `Optional[str]` Id of user that created the knowledge base - **uuid:** `Optional[str]` Unique id for knowledge base - **links:** `Optional[APILinks]` Links to other pages - **meta:** `Optional[APIMeta]` Meta information about the data set ### Example ```python from do_gradientai import GradientAI client = GradientAI() knowledge_bases = client.knowledge_bases.list() print(knowledge_bases.knowledge_bases) ``` ## Delete `knowledge_bases.delete(struuid) -> 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:** `str` ### Returns - `class KnowledgeBaseDeleteResponse` Information about a deleted knowledge base - **uuid:** `Optional[str]` The id of the deleted knowledge base ### Example ```python from do_gradientai import GradientAI client = GradientAI() knowledge_base = client.knowledge_bases.delete( "uuid", ) print(knowledge_base.uuid) ``` ## Domain Types ### API Knowledge Base - `class APIKnowledgeBase` Knowledgebase Description - **added\_to\_agent\_at:** `Optional[datetime]` Time when the knowledge base was added to the agent - **created\_at:** `Optional[datetime]` Creation date / time - **database\_id:** `Optional[str]` - **embedding\_model\_uuid:** `Optional[str]` - **is\_public:** `Optional[bool]` Whether the knowledge base is public or not - **last\_indexing\_job:** `Optional[APIIndexingJob]` IndexingJob description - **name:** `Optional[str]` Name of knowledge base - **project\_id:** `Optional[str]` - **region:** `Optional[str]` Region code - **tags:** `Optional[List[str]]` Tags to organize related resources - **updated\_at:** `Optional[datetime]` Last modified - **user\_id:** `Optional[str]` Id of user that created the knowledge base - **uuid:** `Optional[str]` Unique id for knowledge base