toolmodel

package
v0.1.28 Latest Latest
Warning

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

Go to latest
Published: Oct 10, 2026 License: MIT Imports: 23 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package toolmodel runs local embedding models used for tool retrieval. The model layout and WordPiece implementation are adapted from Pulse (github.com/bryanbarton525/pulse, Apache-2.0 license).

Index

Constants

View Source
const (
	PotionRevision = "1e5a03f8eeb2c98b928fbbd846f22f816360919f"

	MiniLMRevision = "1110a243fdf4706b3f48f1d95db1a4f5529b4d41"
)
View Source
const LayaRevision = "55cf4c4ebb4ebe31b2550e8bdf3bd21b99753851"

Variables

This section is empty.

Functions

func Cosine

func Cosine(a, b []float32) float64

func MiniLMPath

func MiniLMPath(stateDir string) string

func PotionPaths

func PotionPaths(stateDir string) (string, string)

func SetupMiniLM

func SetupMiniLM(ctx context.Context, stateDir string) error

func SetupPotion

func SetupPotion(ctx context.Context, stateDir string) error

SetupPotion downloads pinned official artifacts and prepares a pure-Go format.

Types

type DecisionClient added in v0.1.26

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

DecisionClient calls an explicitly started decision server. A timed-out server exchange disables the adapter until Prism restarts because server inference may still be queued after HTTP cancellation.

func NewDecisionClient added in v0.1.25

func NewDecisionClient(rawURL, apiKeyEnv, model string) (*DecisionClient, error)

NewDecisionClient supports Kev/Jev binary scoring and Laya categorical choices.

func NewKevClient

func NewKevClient(rawURL, apiKeyEnv string) (*DecisionClient, error)

func (*DecisionClient) ModelIdentity added in v0.1.26

func (c *DecisionClient) ModelIdentity() string

func (*DecisionClient) Score added in v0.1.26

func (c *DecisionClient) Score(ctx context.Context, task string, tools []KevTool) ([]float64, error)

func (*DecisionClient) ScoreKind added in v0.1.26

func (c *DecisionClient) ScoreKind() string

ScoreKind distinguishes relative choice probabilities from independent binary scores.

type DecisionTool added in v0.1.26

type DecisionTool struct{ Name, Description string }

type EncodeOptions

type EncodeOptions struct {
	// AddSpecialTokens wraps the sequence in [CLS] and [SEP].
	//
	// Transformers need them: [CLS] is a real position the attention layers
	// read. Static embeddings do not — there is no attention, so a special
	// token would just be one more vector dragging the mean toward a constant.
	AddSpecialTokens bool

	// MaxTokens truncates the sequence. Zero means no limit.
	MaxTokens int
}

EncodeOptions controls how a sequence is prepared for a specific model.

type KevClient

type KevClient = DecisionClient

KevClient preserves compatibility with existing callers.

type KevTool

type KevTool = DecisionTool

KevTool preserves compatibility with existing callers.

type MiniLM

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

MiniLM runs an ONNX sentence embedding graph through Hugot's pure-Go backend.

func LoadMiniLM

func LoadMiniLM(modelPath string) (*MiniLM, error)

func (*MiniLM) Close

func (m *MiniLM) Close() error

func (*MiniLM) Embed

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

type Potion

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

func LoadPotion

func LoadPotion(modelPath, vocabPath string) (*Potion, error)

func (*Potion) Embed

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

type WordPiece

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

WordPiece is a BERT WordPiece tokenizer.

Both embedding tiers use a BERT-family vocabulary, so one pure-Go tokenizer serves both. Implementing it here rather than pulling in a cgo/Rust tokenizer keeps Prism's runtime binary free of cgo entirely.

func LoadWordPiece

func LoadWordPiece(vocabPath string, lowerCase bool) (*WordPiece, error)

LoadWordPiece reads a vocab.txt where line N holds the token with ID N.

func (*WordPiece) Encode

func (w *WordPiece) Encode(text string, options EncodeOptions) []int32

Encode converts text into token IDs.

func (*WordPiece) Size

func (w *WordPiece) Size() int

Size is the number of vocabulary entries.

Jump to

Keyboard shortcuts

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