memory

package module
v0.4.0 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Memory

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

func New

func New(path string) (*Memory, bool, error)

New creates a new memory index if one does not exist at the given path. If one does exist, it opens it. Specify ":memory:" as the path to create a new in-memory index.

func (*Memory) Add

func (m *Memory) Add(id string, content string) error

Add adds a new memory fragment to the index

func (*Memory) Close

func (m *Memory) Close() error

Close closes the index

func (*Memory) Destroy

func (m *Memory) Destroy() error

Destroy closes the index and deletes the index file

func (*Memory) IsIndexed added in v0.3.0

func (m *Memory) IsIndexed(id string) (bool, error)

IsIndexed returns true if the given ID is indexed

func (*Memory) Search

func (m *Memory) Search(query string) ([]MemoryFragment, error)

Search searches the index for the given query

type MemoryFragment

type MemoryFragment struct {
	ID    string
	Score float64
	Avg   float64
}

func SortByAverage added in v0.4.0

func SortByAverage(fragments []MemoryFragment) []MemoryFragment

func SortByScore added in v0.4.0

func SortByScore(fragments []MemoryFragment) []MemoryFragment

func TopFragmentAvg

func TopFragmentAvg(fragments []MemoryFragment) MemoryFragment

TopFragmentAvg returns the fragment with the highest average score

func TopFragmentScore

func TopFragmentScore(fragments []MemoryFragment) MemoryFragment

TopFragmentScore returns the fragment with the highest score

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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