Documentation ¶
Overview ¶
Package chroma contains an implementation of the VectorStore interface that connects to an external Chroma database.
Index ¶
- Constants
- Variables
- type Option
- func WithChromaURL(chromaURL string) Option
- func WithDistanceFunction(distanceFunction chromatypes.DistanceFunction) Option
- func WithEmbedder(e embeddings.Embedder) Option
- func WithIncludes(includes []chromatypes.QueryEnum) Option
- func WithNameSpace(nameSpace string) Option
- func WithOpenAIAPIKey(openAiAPIKey string) Option
- func WithOpenAIOrganization(openAiOrganization string) Option
- type Store
Constants ¶
const ( OpenAIAPIKeyEnvVarName = "OPENAI_API_KEY" // #nosec G101 OpenAIOrgIDEnvVarName = "OPENAI_ORGANIZATION" ChromaURLKeyEnvVarName = "CHROMA_URL" DefaultNameSpace = "langchain" DefaultNameSpaceKey = "nameSpace" DefaultDistanceFunc = chromatypes.L2 )
Variables ¶
var ( ErrInvalidScoreThreshold = errors.New("score threshold must be between 0 and 1") ErrUnexpectedResponseLength = errors.New("unexpected length of response") ErrNewClient = errors.New("error creating collection") ErrAddDocument = errors.New("error adding document") ErrRemoveCollection = errors.New("error resetting collection") ErrUnsupportedOptions = errors.New("unsupported options") )
var ErrInvalidOptions = errors.New("invalid options")
ErrInvalidOptions is returned when the options given are invalid.
Functions ¶
This section is empty.
Types ¶
type Option ¶
type Option func(p *Store)
Option is a function type that can be used to modify the client.
func WithChromaURL ¶
WithChromaURL is an option for specifying the Chroma URL. Must be set.
func WithDistanceFunction ¶
func WithDistanceFunction(distanceFunction chromatypes.DistanceFunction) Option
WithDistanceFunction specifies the distance function which will be used (default is L2) see: https://github.com/amikos-tech/chroma-go/blob/ab1339d0ee1a863be7d6773bcdedc1cfd08e3d77/types/types.go#L22
func WithEmbedder ¶
func WithEmbedder(e embeddings.Embedder) Option
WithEmbedder is an option for setting the embedder to use.
func WithIncludes ¶
func WithIncludes(includes []chromatypes.QueryEnum) Option
WithIncludes is an option for setting the includes to query the vectors.
func WithNameSpace ¶
WithNameSpace sets the nameSpace used to upsert and query the vectors from.
func WithOpenAIAPIKey ¶ added in v0.1.6
WithOpenAIAPIKey is an option for setting the OpenAI api key. If the option is not set the api key is read from the OPENAI_API_KEY environment variable. If the variable is not present, an error will be returned.
func WithOpenAIOrganization ¶ added in v0.1.6
WithOpenAIOrganization is an option for setting the OpenAI organization id.
type Store ¶
type Store struct {
// contains filtered or unexported fields
}
Store is a wrapper around the chromaGo API and client.
func New ¶
New creates an active client connection to the (specified, or default) collection in the Chroma server and returns the `Store` object needed by the other accessors.
func (Store) AddDocuments ¶
func (s Store) AddDocuments(ctx context.Context, docs []schema.Document, options ...vectorstores.Option, ) ([]string, error)
AddDocuments adds the text and metadata from the documents to the Chroma collection associated with 'Store'. and returns the ids of the added documents.