chroma

package
v1.2.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 24, 2023 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	DistanceFnL2 = "l2"
)

Functions

This section is empty.

Types

type DistanceFn

type DistanceFn = string

type Options

type Options func(o *chromaOptions)

func WithAddr

func WithAddr(addr string) Options

WithAddr Sets the address of the remote chroma instance. [Required]

func WithCollection

func WithCollection(name string, metadata map[string]any) Options

WithCollection Sets the collection name to target with this instance of the client. [Required] Can also optionally supply a metadata map to attach to the collection. To work with multiple collections, create a client per collection

func WithDistanceFn

func WithDistanceFn(fn DistanceFn) Options

WithDistanceFn Sets the distance function. Defaults to "l2"/ See Chroma docs for other supported distance functions

func WithEmbedder

func WithEmbedder(e embeddings.Embedder) Options

WithEmbedder Sets the embedder. [Required]

type Store

type Store struct {
	// contains filtered or unexported fields
}

func NewChroma

func NewChroma(opts ...Options) (*Store, error)

func (*Store) AddDocuments

func (c *Store) AddDocuments(_ context.Context, documents []schema.Document, option ...vectorstores.Option) error

AddDocuments to the Chroma collection

func (*Store) ClearCollection

func (c *Store) ClearCollection() error

ClearCollection Drops and recreates the collection. All documents will be lost The original DistanceFn and Metadata are maintained

func (*Store) CollectionName

func (c *Store) CollectionName() string

CollectionName Returns the collection name associated with this instance of the Chroma client

func (*Store) CollectionSize

func (c *Store) CollectionSize() (int, error)

func (*Store) GetAllDocuments

func (c *Store) GetAllDocuments() ([]schema.Document, error)

GetAllDocuments returns *all* the documents in the collection. Useful for debugging, but be careful while using in production.

func (*Store) ResetDB

func (c *Store) ResetDB() error

ResetDB Resets the Chroma DB. See: https://docs.trychroma.com/reference/Client#reset

func (*Store) SimilaritySearch

func (c *Store) SimilaritySearch(_ context.Context, query string, numDocuments int, options ...vectorstores.Option) ([]schema.Document, error)

SimilaritySearch Performs a similarity search on the given query within the collection targeted by this client. Note: If a distance Threshold is set, the number of documents returned can be *lower* than the requested numDocuments

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL