embedding

package
v0.59.5 Latest Latest
Warning

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

Go to latest
Published: Feb 3, 2026 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// ModelRepo is the Hugging Face model repository
	ModelRepo = "sentence-transformers/all-MiniLM-L6-v2"
	// EmbeddingDimension is the dimension of the embedding vectors
	EmbeddingDimension = 384
	// DefaultModelDir is the default directory for model files
	DefaultModelDir = ".mcp-devtools/models"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	ModelPath    string
	RuntimePath  string
	BatchSize    int
	MaxSeqLength int
}

Config holds configuration for the embedding engine

type Engine

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

Engine provides embedding generation using a local ONNX model via hugot

func NewEngine

func NewEngine(config Config, logger *logrus.Logger) (*Engine, error)

NewEngine creates a new embedding engine

func (*Engine) Close

func (e *Engine) Close() error

Close releases resources

func (*Engine) Dimension

func (e *Engine) Dimension() int

Dimension returns the embedding dimension

func (*Engine) Embed

func (e *Engine) Embed(ctx context.Context, text string) ([]float32, error)

Embed generates an embedding for the given text

func (*Engine) EmbedBatch

func (e *Engine) EmbedBatch(ctx context.Context, texts []string) ([][]float32, error)

EmbedBatch generates embeddings for multiple texts

func (*Engine) EnsureReady

func (e *Engine) EnsureReady(ctx context.Context) error

EnsureReady ensures the model and runtime are downloaded and loaded

func (*Engine) IsLoaded

func (e *Engine) IsLoaded() bool

IsLoaded returns whether the model is loaded

func (*Engine) IsRuntimeLoaded

func (e *Engine) IsRuntimeLoaded() bool

IsRuntimeLoaded returns whether the runtime is loaded

func (*Engine) ModelPath

func (e *Engine) ModelPath() string

ModelPath returns the path to the loaded model

func (*Engine) RuntimeVersion

func (e *Engine) RuntimeVersion() string

RuntimeVersion returns the runtime version

Jump to

Keyboard shortcuts

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