vectorstore

package
v0.0.110 Latest Latest
Warning

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

Go to latest
Published: Mar 29, 2024 License: MIT Imports: 16 Imported by: 0

Documentation

Overview

Package vectorstore provides functionality for storing and managing vector embeddings.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ToRetriever

func ToRetriever(vectorStore schema.VectorStore, optFns ...func(o *retriever.VectorStoreOptions)) schema.Retriever

ToRetriever takes a vector store and returns a retriever

Types

type DistanceFunc added in v0.0.104

type DistanceFunc func(v1, v2 []float32) (float32, error)

DistanceFunc represents a function for calculating the distance between two vectors

type InMemory added in v0.0.102

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

InMemory represents an in-memory vector store.

func NewInMemory added in v0.0.102

func NewInMemory(embedder schema.Embedder, optFns ...func(*InMemoryOptions)) *InMemory

NewInMemory creates a new instance of the in-memory vector store.

func (*InMemory) AddDocuments added in v0.0.102

func (vs *InMemory) AddDocuments(ctx context.Context, docs []schema.Document) error

AddDocuments adds a batch of documents to the InMemory vector store.

func (*InMemory) AddItem added in v0.0.102

func (vs *InMemory) AddItem(item InMemoryItem)

AddItem adds a single item to the InMemory vector store.

func (*InMemory) Data added in v0.0.102

func (vs *InMemory) Data() []InMemoryItem

Data returns the underlying data stored in the InMemory vector store.

func (*InMemory) Load added in v0.0.105

func (vs *InMemory) Load(r io.Reader) error

func (*InMemory) Save added in v0.0.105

func (vs *InMemory) Save(w io.Writer) error

Save saves the data to an io.Writer.

func (*InMemory) SimilaritySearch added in v0.0.102

func (vs *InMemory) SimilaritySearch(ctx context.Context, query string) ([]schema.Document, error)

SimilaritySearch performs a similarity search with the given query in the InMemory vector store.

type InMemoryItem added in v0.0.102

type InMemoryItem struct {
	Content  string         `json:"content"`
	Vector   []float32      `json:"vector"`
	Metadata map[string]any `json:"metadata"`
}

InMemoryItem represents an item stored in memory with its content, vector, and metadata.

type InMemoryOptions added in v0.0.102

type InMemoryOptions struct {
	TopK         int
	DistanceFunc DistanceFunc
}

InMemoryOptions represents options for the in-memory vector store.

type Pinecone added in v0.0.12

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

func NewPinecone added in v0.0.12

func NewPinecone(client pinecone.Client, embedder schema.Embedder, textKey string, optFns ...func(*PineconeOptions)) (*Pinecone, error)

func (*Pinecone) AddDocuments added in v0.0.12

func (vs *Pinecone) AddDocuments(ctx context.Context, docs []schema.Document) error

func (*Pinecone) SimilaritySearch added in v0.0.12

func (vs *Pinecone) SimilaritySearch(ctx context.Context, query string) ([]schema.Document, error)

type PineconeOptions added in v0.0.12

type PineconeOptions struct {
	Namespace string
	TopK      int64
}

type Weaviate added in v0.0.40

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

Weaviate represents a Weaviate vector store.

func NewWeaviate added in v0.0.40

func NewWeaviate(client *weaviate.Client, embedder schema.Embedder, optFns ...func(*WeaviateOptions)) *Weaviate

NewWeaviate creates a new Weaviate vector store with the given Weaviate client, embedder, and optional configuration options.

func (*Weaviate) AddDocuments added in v0.0.40

func (vs *Weaviate) AddDocuments(ctx context.Context, docs []schema.Document) error

AddDocuments adds a batch of documents to the Weaviate vector store.

func (*Weaviate) CreateClassIfNotExist added in v0.0.41

func (vs *Weaviate) CreateClassIfNotExist(ctx context.Context) error

CreateClassIfNotExist checks if the Weaviate class for the vector store exists, and creates it if it doesn't.

func (*Weaviate) Delete added in v0.0.41

func (vs *Weaviate) Delete(ctx context.Context, uuid string) error

Delete removes a document from the Weaviate vector store based on its UUID.

func (*Weaviate) SimilaritySearch added in v0.0.40

func (vs *Weaviate) SimilaritySearch(ctx context.Context, query string) ([]schema.Document, error)

SimilaritySearch performs a similarity search with the given query in the Weaviate vector store.

type WeaviateOptions added in v0.0.40

type WeaviateOptions struct {
	// TextKey is the name of the property in the Weaviate objects where the text content is stored.
	TextKey string

	// TopK is the number of documents to retrieve in similarity search.
	TopK int

	// IndexName is the name of the index to store the vectors.
	IndexName string

	// AdditionalFields is a list of additional fields to retrieve during similarity search.
	AdditionalFields []string
}

WeaviateOptions contains options for configuring the Weaviate vector store.

Jump to

Keyboard shortcuts

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