types

package
v0.1.3 Latest Latest
Warning

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

Go to latest
Published: Mar 27, 2024 License: MIT Imports: 14 Imported by: 2

Documentation

Index

Constants

View Source
const (
	L2                 DistanceFunction = "l2"
	COSINE             DistanceFunction = "cosine"
	IP                 DistanceFunction = "ip"
	DefaultTenant                       = "default_tenant"
	DefaultDatabase                     = "default_database"
	IDocuments         QueryEnum        = "documents"
	IEmbeddings        QueryEnum        = "embeddings"
	IMetadatas         QueryEnum        = "metadatas"
	IDistances         QueryEnum        = "distances"
	HNSWSpace                           = "hnsw:space"
	HNSWConstructionEF                  = "hnsw:construction_ef"
	HNSWBatchSize                       = "hnsw:batch_size"
	HNSWSyncThreshold                   = "hnsw:sync_threshold"
	HNSWM                               = "hnsw:M"
	HNSWSearchEF                        = "hnsw:search_ef"
	HNSWNumThreads                      = "hnsw:num_threads"
	HNSWResizeFactor                    = "hnsw:resize_factor"
	DefaultTimeout                      = 30 * time.Second
)

Variables

This section is empty.

Functions

func EmbedRecordsDefaultImpl

func EmbedRecordsDefaultImpl(e EmbeddingFunction, ctx context.Context, records []*Record, force bool) error

func ToAPIEmbeddings

func ToAPIEmbeddings(embeddings []*Embedding) []openapi.EmbeddingsInner

Types

type BasicAuthCredentialsProvider added in v0.1.1

type BasicAuthCredentialsProvider struct {
	Username string
	Password string
}

func NewBasicAuthCredentialsProvider added in v0.1.1

func NewBasicAuthCredentialsProvider(username, password string) *BasicAuthCredentialsProvider

func (*BasicAuthCredentialsProvider) Authenticate added in v0.1.1

func (b *BasicAuthCredentialsProvider) Authenticate(config *openapi.Configuration) error

type CollectionQueryBuilder

type CollectionQueryBuilder struct {
	QueryTexts      []string
	QueryEmbeddings []*Embedding
	Where           map[string]interface{}
	WhereDocument   map[string]interface{}
	NResults        int32
	Include         []QueryEnum
	Offset          int32
	Limit           int32
	Ids             []string
}

type CollectionQueryOption

type CollectionQueryOption func(*CollectionQueryBuilder) error

func WithIds

func WithIds(ids []string) CollectionQueryOption

func WithInclude

func WithInclude(include ...QueryEnum) CollectionQueryOption

func WithLimit

func WithLimit(limit int32) CollectionQueryOption

func WithNResults

func WithNResults(nResults int32) CollectionQueryOption

func WithOffset

func WithOffset(offset int32) CollectionQueryOption

func WithQueryEmbedding

func WithQueryEmbedding(queryEmbedding *Embedding) CollectionQueryOption

func WithQueryEmbeddings

func WithQueryEmbeddings(queryEmbeddings []*Embedding) CollectionQueryOption

func WithQueryText

func WithQueryText(queryText string) CollectionQueryOption

func WithQueryTexts

func WithQueryTexts(queryTexts []string) CollectionQueryOption

func WithWhere

func WithWhere(operation where.WhereOperation) CollectionQueryOption

func WithWhereDocumentMap

func WithWhereDocumentMap(where map[string]interface{}) CollectionQueryOption

func WithWhereMap

func WithWhereMap(where map[string]interface{}) CollectionQueryOption

type ConsistentHashEmbeddingFunction

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

func (*ConsistentHashEmbeddingFunction) EmbedDocuments

func (e *ConsistentHashEmbeddingFunction) EmbedDocuments(ctx context.Context, documents []string) ([]*Embedding, error)

func (*ConsistentHashEmbeddingFunction) EmbedQuery

func (e *ConsistentHashEmbeddingFunction) EmbedQuery(_ context.Context, document string) (*Embedding, error)

func (*ConsistentHashEmbeddingFunction) EmbedRecords

func (e *ConsistentHashEmbeddingFunction) EmbedRecords(ctx context.Context, records []*Record, force bool) error

type CredentialsProvider added in v0.1.1

type CredentialsProvider interface {
	Authenticate(apiClient *openapi.Configuration) error
}

type DistanceFunction

type DistanceFunction string

func ToDistanceFunction

func ToDistanceFunction(str any) (DistanceFunction, error)

type Embedding

type Embedding struct {
	ArrayOfFloat32 *[]float32
	ArrayOfInt32   *[]int32
}

func NewEmbeddingFromAPI

func NewEmbeddingFromAPI(apiEmbedding openapi.EmbeddingsInner) *Embedding

func NewEmbeddingFromFloat32

func NewEmbeddingFromFloat32(embedding []float32) *Embedding

func NewEmbeddingFromInt32

func NewEmbeddingFromInt32(embedding []int32) *Embedding

func NewEmbeddings

func NewEmbeddings(embeddings []interface{}) (*Embedding, error)

func NewEmbeddingsFromFloat32

func NewEmbeddingsFromFloat32(embeddings [][]float32) []*Embedding

func (*Embedding) GetFloat32

func (e *Embedding) GetFloat32() *[]float32

func (*Embedding) GetInt32

func (e *Embedding) GetInt32() *[]int32

func (*Embedding) IsDefined

func (e *Embedding) IsDefined() bool

func (*Embedding) String

func (e *Embedding) String() string

func (*Embedding) ToAPI

func (e *Embedding) ToAPI() openapi.EmbeddingsInner

type EmbeddingFunction

type EmbeddingFunction interface {
	// EmbedDocuments returns a vector for each text.
	EmbedDocuments(ctx context.Context, texts []string) ([]*Embedding, error)
	// EmbedQuery embeds a single text.
	EmbedQuery(ctx context.Context, text string) (*Embedding, error)
	EmbedRecords(ctx context.Context, records []*Record, force bool) error
}

func NewConsistentHashEmbeddingFunction

func NewConsistentHashEmbeddingFunction() EmbeddingFunction

type IDGenerator

type IDGenerator interface {
	Generate(document string) string
}

type InvalidEmbeddingValueError

type InvalidEmbeddingValueError struct {
	Value interface{}
}

func (*InvalidEmbeddingValueError) Error

type InvalidMetadataValueError

type InvalidMetadataValueError struct {
	Key   string
	Value interface{}
}

func (*InvalidMetadataValueError) Error

func (e *InvalidMetadataValueError) Error() string

type Option

type Option func(*Record) error

func WithDocument

func WithDocument(document string) Option

func WithEmbedding

func WithEmbedding(embedding Embedding) Option

func WithID

func WithID(id string) Option

func WithMetadata

func WithMetadata(key string, value interface{}) Option

func WithMetadatas

func WithMetadatas(metadata map[string]interface{}) Option

func WithURI

func WithURI(uri string) Option

type QueryEnum

type QueryEnum string

type Record

type Record struct {
	ID        string
	Embedding Embedding
	Metadata  map[string]interface{}
	Document  string
	URI       string
	// contains filtered or unexported fields
}

func (*Record) Validate

func (r *Record) Validate() error

Validate checks if the record is valid

type RecordSet

type RecordSet struct {
	Records           []*Record
	IDGenerator       IDGenerator
	EmbeddingFunction EmbeddingFunction
}

func NewRecordSet

func NewRecordSet(opts ...RecordSetOption) (*RecordSet, error)

func (*RecordSet) BuildAndValidate

func (rs *RecordSet) BuildAndValidate(ctx context.Context) ([]*Record, error)

func (*RecordSet) GetDocuments

func (rs *RecordSet) GetDocuments() []string

func (*RecordSet) GetEmbeddings

func (rs *RecordSet) GetEmbeddings() []*Embedding

func (*RecordSet) GetIDs

func (rs *RecordSet) GetIDs() []string

func (*RecordSet) GetMetadatas

func (rs *RecordSet) GetMetadatas() []map[string]interface{}

func (*RecordSet) GetURIs

func (rs *RecordSet) GetURIs() []string

func (*RecordSet) Validate

func (rs *RecordSet) Validate() error

Validate the whole record set by calling record.Validate

func (*RecordSet) WithRecord

func (rs *RecordSet) WithRecord(recordOpts ...Option) *RecordSet

func (*RecordSet) WithRecords

func (rs *RecordSet) WithRecords(records []*Record) *RecordSet

type RecordSetOption

type RecordSetOption func(*RecordSet) error

func WithEmbeddingFunction

func WithEmbeddingFunction(embeddingFunction EmbeddingFunction) RecordSetOption

WithEmbeddingFunction sets the embedding function to be used for in place embedding.

func WithIDGenerator

func WithIDGenerator(idGenerator IDGenerator) RecordSetOption

type SHA256Generator

type SHA256Generator struct{}

func NewSHA256Generator

func NewSHA256Generator() *SHA256Generator

func (*SHA256Generator) Generate

func (s *SHA256Generator) Generate(document string) string

type TokenAuthCredentialsProvider added in v0.1.1

type TokenAuthCredentialsProvider struct {
	Token  string
	Header TokenTransportHeader
}

func NewTokenAuthCredentialsProvider added in v0.1.1

func NewTokenAuthCredentialsProvider(token string, header TokenTransportHeader) *TokenAuthCredentialsProvider

func (*TokenAuthCredentialsProvider) Authenticate added in v0.1.1

func (t *TokenAuthCredentialsProvider) Authenticate(config *openapi.Configuration) error

type TokenTransportHeader added in v0.1.1

type TokenTransportHeader string
const (
	AuthorizationTokenHeader TokenTransportHeader = "Authorization"
	XChromaTokenHeader       TokenTransportHeader = "X-Chroma-Token"
)

type ULIDGenerator

type ULIDGenerator struct{}

func NewULIDGenerator

func NewULIDGenerator() *ULIDGenerator

func (*ULIDGenerator) Generate

func (u *ULIDGenerator) Generate(_ string) string

type UUIDGenerator

type UUIDGenerator struct{}

func NewUUIDGenerator

func NewUUIDGenerator() *UUIDGenerator

func (*UUIDGenerator) Generate

func (u *UUIDGenerator) Generate(_ string) string

Jump to

Keyboard shortcuts

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