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
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 ¶
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.