embeddings

package
v3.23.1 Latest Latest
Warning

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

Go to latest
Published: Sep 14, 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) 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. The vector width is not assumed up front — it is derived from the store itself: from an existing file's header, inferred as legacyDimension for a headerless pre-existing file, or established by whatever vector the first Write receives.

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 explicitly establishes the vector width, bypassing auto-detection. Intended for tests that want a small, fast vector width; production callers should let Write/Find derive the width from the store itself rather than supplying one.

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