vdb

package
v0.10.0 Latest Latest
Warning

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

Go to latest
Published: Jun 16, 2025 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Register added in v0.0.8

func Register(name string, constructor func(config any) (VDB, error))

Register ...

Types

type Distance added in v0.0.9

type Distance string
const (
	DistanceL2     Distance = "l2"
	DistanceCosine Distance = "cosine"
)

type Document

type Document struct {
	ID          string          `json:"id"`
	Title       string          `json:"title"`
	Content     string          `json:"content"`
	ContentHash string          `json:"content_hash"`
	Embedding   pgvector.Vector `json:"embedding"`
	Similarity  float32         `json:"similarity"`
	Metadata    map[string]any  `json:"metadata"`
	CreatedAt   time.Time       `json:"created_at"`
	UpdatedAt   time.Time       `json:"updated_at"`
}

Document 文档

type SearchOption

type SearchOption func(*SearchOptions)

SearchOption 搜索选项

func WithThreshold

func WithThreshold(threshold float64) SearchOption

WithThreshold 设置相似度阈值

func WithTopk

func WithTopk(topk int) SearchOption

WithTopk 设置返回结果数量

type SearchOptions

type SearchOptions struct {
	TopK      int     // 返回结果数量限制
	Threshold float64 // 相似度阈值
}

SearchOptions 搜索配置

type VDB

type VDB interface {
	Create(context.Context) error
	Store(context.Context, ...*Document) error

	SearchWithOptions(context.Context, []float32, *SearchOptions) ([]*Document, error)
	Search(context.Context, []float32, ...SearchOption) ([]*Document, error)
	SearchQuery(context.Context, string, ...SearchOption) ([]*Document, error)
	SearchQueryWithOptions(context.Context, string, *SearchOptions) ([]*Document, error)

	Delete(context.Context, string) error
	Close() error
}

VDB ...

func NewVDB added in v0.0.8

func NewVDB(name string, config any) (VDB, error)

NewVDB ...

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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