Class: ChromaClient
Constructorsโ
constructorโ
โข new ChromaClient(params?)
Creates a new ChromaClient instance.
Example
const client = new ChromaClient({
path: "http://localhost:8000"
});
Parametersโ
| Name | Type | Description |
|---|---|---|
params | Object | The parameters for creating a new client |
params.path? | string | The base path for the Chroma API. |
Methodsโ
createCollectionโ
โธ createCollection(params): Promise<Collection>
Creates a new collection with the specified properties.
Throws
If there is an issue creating the collection.
Example
const collection = await client.createCollection({
name: "my_collection",
metadata: {
"description": "My first collection"
}
});
Parametersโ
| Name | Type | Description |
|---|---|---|
params | Object | The parameters for creating a new collection. |
params.embeddingFunction? | IEmbeddingFunction | Optional custom embedding function for the collection. |
params.metadata? | CollectionMetadata | Optional metadata associated with the collection. |
params.name | string | The name of the collection. |
Returnsโ
Promise<Collection>
A promise that resolves to the created collection.
deleteCollectionโ
โธ deleteCollection(params): Promise<void>
Deletes a collection with the specified name.
Throws
If there is an issue deleting the collection.
Example
await client.deleteCollection({
name: "my_collection"
});
Parametersโ
| Name | Type | Description |
|---|---|---|
params | Object | The parameters for deleting a collection. |
params.name | string | The name of the collection. |
Returnsโ
Promise<void>
A promise that resolves when the collection is deleted.
getCollectionโ
โธ getCollection(params): Promise<Collection>
Gets a collection with the specified name.
Throws
If there is an issue getting the collection.
Example
const collection = await client.getCollection({
name: "my_collection"
});
Parametersโ
| Name | Type | Description |
|---|---|---|
params | Object | The parameters for getting a collection. |
params.embeddingFunction? | IEmbeddingFunction | Optional custom embedding function for the collection. |
params.name | string | The name of the collection. |
Returnsโ
Promise<Collection>
A promise that resolves to the collection.
getOrCreateCollectionโ
โธ getOrCreateCollection(params): Promise<Collection>
Gets or creates a collection with the specified properties.
Throws
If there is an issue getting or creating the collection.
Example
const collection = await client.getOrCreateCollection({
name: "my_collection",
metadata: {
"description": "My first collection"
}
});
Parametersโ
| Name | Type | Description |
|---|---|---|
params | Object | The parameters for creating a new collection. |
params.embeddingFunction? | IEmbeddingFunction | Optional custom embedding function for the collection. |
params.metadata? | CollectionMetadata | Optional metadata associated with the collection. |
params.name | string | The name of the collection. |
Returnsโ
Promise<Collection>
A promise that resolves to the got or created collection.
heartbeatโ
โธ heartbeat(): Promise<number>
Returns a heartbeat from the Chroma API.
Example
const heartbeat = await client.heartbeat();
Returnsโ
Promise<number>
A promise that resolves to the heartbeat from the Chroma API.
listCollectionsโ
โธ listCollections(): Promise<CollectionType[]>
Lists all collections.
Throws
If there is an issue listing the collections.
Example
const collections = await client.listCollections();
Returnsโ
Promise<CollectionType[]>
A promise that resolves to a list of collection names.
resetโ
โธ reset(): Promise<Reset200Response>
Resets the state of the object by making an API call to the reset endpoint.
Throws
If there is an issue resetting the state.
Example
await client.reset();
Returnsโ
Promise<Reset200Response>
A promise that resolves when the reset operation is complete.
versionโ
โธ version(): Promise<string>
Returns the version of the Chroma API.
Example
const version = await client.version();
Returnsโ
Promise<string>
A promise that resolves to the version of the Chroma API.