fti

package
v0.0.0-...-7b96089 Latest Latest
Warning

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

Go to latest
Published: Jun 30, 2023 License: AGPL-3.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type FlatKVIndex

type FlatKVIndex[K comparable] struct {
	// contains filtered or unexported fields
}

func NewFlatKVIndex

func NewFlatKVIndex[K comparable]() (*FlatKVIndex[K], error)

NewFlatKVIndex initializes a new OnlineIndex with the given repository. It returns a pointer to the created FlatKVIndex and an error if any.

NewFlatKVIndex takes a repo *Repository as input and creates a new OnlineIndex instance. It initializes the FlatKVIndex struct with the repo and an empty mapping. The function then creates a new Faiss index using faiss.NewIndexFlatIP with a dimension of 1536 and assigns it to the idx field of the FlatKVIndex struct. If an error occurs during the creation of the index, it returns nil and the error. Otherwise, it returns a pointer to the created FlatKVIndex and nil error.

func (*FlatKVIndex[K]) Add

func (oi *FlatKVIndex[K]) Add(key K, value ...llm.Embedding) error

Add adds an image to the online index. It takes an ObjectSnapshotImage as input and adds its embeddings to the index.

The function initializes a write lock, which ensures the thread-safety of the online index. The function then calculates the base index as the total number of entries in the index. For each embedding in the image, the function creates an FlatKVIndexEntry, which holds the index, chunk, and embedding of the image. It then calls the putEntry() function to store the entry in the repository. Finally, it adds the embedding to the faiss index. If any error occurs during the process, it returns the error. Otherwise, it returns nil.

func (*FlatKVIndex[K]) Close

func (oi *FlatKVIndex[K]) Close()

func (*FlatKVIndex[K]) Delete

func (oi *FlatKVIndex[K]) Delete(key K) bool

func (*FlatKVIndex[K]) Query

func (oi *FlatKVIndex[K]) Query(q llm.Embedding, k int64) ([]indexing.SearchHit[K], error)

Query performs a search in the online index using the given query embedding and returns a list of hits. Each hit contains the corresponding entry from the index and the distance between the query and the entry embedding.

type IndexObject

type IndexObject[K comparable] struct {
	Key        K
	References []int64
}

type RerankIndex

type RerankIndex[K comparable] struct {
	// contains filtered or unexported fields
}

func NewRerankIndex

func NewRerankIndex[K comparable](sources ...indexing.Index[K]) *RerankIndex[K]

func (*RerankIndex[K]) Query

func (r *RerankIndex[K]) Query(q llm.Embedding, k int64) ([]indexing.SearchHit[K], error)

Query searches for files in the repository that are similar to the provided query. It takes a context, which can be used for cancellation, the query string, and the maximum number of results (k) to return. The function returns a slice of OnlineIndexQueryHit, which contains information about the matching files, and an error, if any.

Jump to

Keyboard shortcuts

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