embeddings

package
v1.3.0 Latest Latest
Warning

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

Go to latest
Published: Mar 17, 2026 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ExtractTextFromRecord

func ExtractTextFromRecord(title, intent string, constraints []string) string

ExtractTextFromRecord extracts the text to embed from a provenance record Uses full title, complete intent, and all constraints for rich semantic content

Types

type Client

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

Client generates embeddings via a configured API

func NewClient

func NewClient(cfg config.EmbeddingConfig) (*Client, error)

NewClient creates a new embedding client from configuration

func (*Client) Dimension

func (c *Client) Dimension() int

Dimension returns the embedding dimension (2048 for both voyage-4-large and voyage-4-lite)

func (*Client) Generate

func (c *Client) Generate(text string) ([]float32, error)

Generate creates an embedding vector for the given text (backward compatibility)

func (*Client) GenerateDocument

func (c *Client) GenerateDocument(text string) ([]float32, error)

GenerateDocument creates an embedding using 'document' input_type (for indexing)

func (*Client) GenerateQuery

func (c *Client) GenerateQuery(text string) ([]float32, error)

GenerateQuery creates an embedding using 'query' input_type (for searching)

func (*Client) IndexOnComplete

func (c *Client) IndexOnComplete() bool

IndexOnComplete returns whether to generate embeddings on complete

func (*Client) IsConfigured

func (c *Client) IsConfigured() bool

IsConfigured returns true if the client has valid configuration

func (*Client) SimilarityThreshold

func (c *Client) SimilarityThreshold() float64

SimilarityThreshold returns the configured similarity threshold

type RecordEmbedding

type RecordEmbedding struct {
	RecordID string
	Vector   []float32
}

RecordEmbedding stores an embedding vector for a provenance record

type SearchResult

type SearchResult struct {
	RecordID   string
	Similarity float64
}

SearchResult represents a similarity search result

type Store

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

Store manages the local embedding storage at .linespec/embeddings.bin

func NewStore

func NewStore(repoRoot string) *Store

NewStore creates a new embedding store

func (*Store) Delete

func (s *Store) Delete(recordID string) error

Delete removes an embedding for a record

func (*Store) Exists

func (s *Store) Exists(recordID string) (bool, error)

Exists returns true if an embedding exists for the record

func (*Store) Find

func (s *Store) Find(query []float32, topN int) ([]SearchResult, error)

Find searches for similar embeddings using brute-force cosine similarity Returns results sorted by similarity (highest first), limited to topN results

func (*Store) ReadAll

func (s *Store) ReadAll() ([]RecordEmbedding, error)

ReadAll reads all embeddings from the store

func (*Store) SetDimension

func (s *Store) SetDimension(dim int)

SetDimension allows overriding the default dimension (for testing)

func (*Store) Write

func (s *Store) Write(embedding RecordEmbedding) error

Write stores an embedding vector for a record

Jump to

Keyboard shortcuts

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