Chroma.Collection (chroma v0.1.1)

Chroma Collection methods.

Summary

Functions

Adds a batch of embeddings in the database.

Counts all embeddings from a collection.

Creates a collection.

Deletes a collection by name.

Gets a collection by name.

Gets or create a collection by name.

Lists all collections.

It updates the name and metadata of a collection.

Creates a new Chroma.Collection struct.

Updates a batch of embeddings in the database.

Upserts a batch of embeddings in the database

Functions

Link to this function

add(collection, data)

@spec add(%{id: any()}, map()) :: {:error, any()} | {:ok, any()}

Adds a batch of embeddings in the database.

Link to this function

count(collection)

@spec count(%{id: any()}) :: {:error, any()} | {:ok, any()}

Counts all embeddings from a collection.

Examples:

iex> Chroma.Collection.count(%Chroma.Collection{id: "123"})
{:ok, 100}
Link to this function

create(name, metadata \\ %{})

@spec create(String.t(), map()) ::
  {:error, any()} | {:ok, %{id: any(), metadata: any(), name: any()}}

Creates a collection.

Examples:

iex> Chroma.Collection.create("my_collection", metadata: %{type: "test"})
{:ok, %Chroma.Collection{id: "123", name: "my_collection", metadata: %{type: "test"}}}
Link to this function

delete(collection)

@spec delete(%{name: String.t()}) :: {:error, any()} | {:ok, any()}

Deletes a collection by name.

Examples:

iex> Chroma.Collection.delete("my_collection")
{:ok, nil}
@spec get(any()) ::
  {:error, any()} | {:ok, %{id: any(), metadata: any(), name: any()}}

Gets a collection by name.

Examples:

iex> Chroma.Collection.get("my_collection")
{:ok, %Chroma.Collection{id: "123", name: "my_collection", metadata: %{}}}
Link to this function

get_or_create(name, metadata \\ %{})

@spec get_or_create(String.t(), map()) ::
  {:error, any()} | {:ok, %{id: any(), metadata: any(), name: any()}}

Gets or create a collection by name.

Examples:

iex> Chroma.Collection.get_or_create("my_collection", metadata: %{type: "test"})
{:ok, %Chroma.Collection{id: "123", name: "my_collection", metadata: %{type: "test"})}}
@spec list() :: {:error, any()} | {:ok, list()}

Lists all collections.

Examples:

iex> Chroma.Collection.list()
{:ok, [%Chroma.Collection{id: "123", name: "my_collection", metadata: %{}}]}
Link to this function

modify(collection, kwargs)

@spec modify(%{id: any()}, %{name: String.t(), metatada: map()}) ::
  {:error, any()} | {:ok, any()}

It updates the name and metadata of a collection.

Examples:

iex> Chroma.Collection.modify(%Chroma.Collection{id: "123"}, name: "new_name")
{:ok, %Chroma.Collection{id: "123", name: "new_name", metadata: %{}}}
iex> Chroma.Collection.modify(%Chroma.Collection{id: "123"}, metadata: %{type: "test"})
{:ok, %Chroma.Collection{id: "123", name: "new_name", metadata: %{type: "test"}}}
iex> Chroma.Collection.modify(%Chroma.Collection{id: "123"}, %{name: "new_name", metadata: %{type: "test"}})
{:ok, %Chroma.Collection{id: "123", name: "new_name", metadata: %{type: "test"}}}
@spec new(map()) :: %{id: any(), metadata: any(), name: any()}

Creates a new Chroma.Collection struct.

Examples:

iex> Chroma.Collection.new(%{"id" => "123", "name" => "my_collection", "metadata" => %{}})
%Chroma.Collection{id: "123", name: "my_collection", metadata: %{}}
Link to this function

query(collection, embeddings, options)

@spec query(%{id: any()}, any(), map()) :: {:error, any()} | {:ok, any()}
Link to this function

update(collection, data)

Updates a batch of embeddings in the database.

Link to this function

upsert(collection, data)

@spec upsert(%{id: any()}, %{embeddings: map()}) :: {:error, any()} | {:ok, any()}

Upserts a batch of embeddings in the database