database

package
v0.0.0-...-83ee790 Latest Latest
Warning

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

Go to latest
Published: May 27, 2023 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ErrorFileNotFound = "file not found"
)

Variables

This section is empty.

Functions

func Store

func Store(filePath string, embeddings []Document) error

Types

type Database

type Database struct {
	Documents []Document
	// contains filtered or unexported fields
}

func New

func New(filePath string) (*Database, error)

func (*Database) Add

func (db *Database) Add(doc Document)

func (*Database) GetEmbeddingByIndex

func (db *Database) GetEmbeddingByIndex(i int) []float64

func (*Database) GetEmbeddings

func (db *Database) GetEmbeddings() [][]float64

func (*Database) GetTextByIndex

func (db *Database) GetTextByIndex(i int) string

func (*Database) GetTexts

func (db *Database) GetTexts() []string

func (*Database) RemoveByIndex

func (db *Database) RemoveByIndex(i int)

func (*Database) RemoveByText

func (db *Database) RemoveByText(text string)

func (*Database) Save

func (db *Database) Save() error

type DatabaseInterface

type DatabaseInterface interface {
	Add(doc Document)
	Save() error
	Close() error
	GetTextByIndex(i int) string
	GetEmbeddingByIndex(i int) []float64
	GetEmbeddings() [][]float64
	GetTexts() []string
}

type Document

type Document struct {
	Text      string    `json:"text"`
	Embedding []float64 `json:"embedding"`
}

func Load

func Load(filePath string) ([]Document, error)

Jump to

Keyboard shortcuts

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