vdb

package
v0.0.0-...-3b1504f Latest Latest
Warning

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

Go to latest
Published: Apr 3, 2025 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Vector

type Vector struct {
	Values []float32 // len(values) is the dimensions
}

Vector is a wrapper around a slice of float64s, this enables vector addition with methods like v1.Add(v2)

func (*Vector) Add

func (v *Vector) Add(u *Vector) *Vector

func (*Vector) Equals

func (v *Vector) Equals(u *Vector) bool

func (*Vector) Norm

func (v *Vector) Norm() float32

func (*Vector) String

func (v *Vector) String() string

func (*Vector) Sub

func (v *Vector) Sub(u *Vector) *Vector

type VectorDatabase

type VectorDatabase struct {
	DB *sqlite3.Conn
	// contains filtered or unexported fields
}

VectorDatabase represents a file-backed SQLite db with sqlite-vec extension that will store all the embeddings for the git repo. The modelname is stored because it is necessary know since it is necessary to work with the vectors later. Different models have a vectors of different dimension.

func Open

func Open(filename string, modelname string) (*VectorDatabase, error)

Open will attempt to find the SQLite db at filename, and if that fails, then create it, and if the creation fails, it will return an error

func (*VectorDatabase) Close

func (vectordb *VectorDatabase) Close() error

func (*VectorDatabase) CreateTableIdempotent

func (vectordb *VectorDatabase) CreateTableIdempotent(dim int) error

CreateTableIdempotent takes the dimension, this was to decouple the vdb from the ollm package

func (*VectorDatabase) Get

func (vectordb *VectorDatabase) Get(id string) *Vector

func (*VectorDatabase) Insert

func (vectordb *VectorDatabase) Insert(id string, embedding *Vector) error

func (*VectorDatabase) TableName

func (vectordb *VectorDatabase) TableName() string

func (*VectorDatabase) Update

func (vectordb *VectorDatabase) Update(id string, input string) error

Jump to

Keyboard shortcuts

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