Help us shape the future of Go! Take the 2026 Go Developer Survey

embedding

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Mar 22, 2026 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client interface {
	Embed(ctx context.Context, text string) ([]float32, error)
}

Client generates embeddings for text.

type EmbeddingStore

type EmbeddingStore interface {
	StoreTriggerEmbedding(ctx context.Context, recordID string, embedding []float32, model string) error
	GetTriggerEmbedding(ctx context.Context, recordID string) ([]float32, error)
}

EmbeddingStore is the narrow vector-storage interface needed by Service.

type HTTPClient

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

HTTPClient calls an OpenAI-compatible embeddings endpoint.

func NewHTTPClient

func NewHTTPClient(endpoint, model, apiKey string, dimensions int) *HTTPClient

NewHTTPClient creates a new HTTP embedding client.

func (*HTTPClient) Embed

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

Embed generates an embedding for text.

type Service

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

Service coordinates query-time and write-time embedding operations.

func NewService

func NewService(client Client, store storage.Store, vectorStore EmbeddingStore, model string) *Service

NewService creates a new embedding service.

func (*Service) BackfillMissing

func (s *Service) BackfillMissing(ctx context.Context) (int, error)

BackfillMissing computes embeddings for existing competence and plan graph records that do not have one.

func (*Service) EmbedQuery

func (s *Service) EmbedQuery(ctx context.Context, taskDescriptor string) ([]float32, error)

EmbedQuery generates an embedding for the given task descriptor.

func (*Service) EmbedRecord

func (s *Service) EmbedRecord(ctx context.Context, rec *schema.MemoryRecord) error

EmbedRecord generates and persists the trigger embedding for a record when supported.

func (*Service) Similarity

func (s *Service) Similarity(ctx context.Context, recordID string, query []float32) (float64, bool)

Similarity returns the cosine similarity in [0, 1] between query and a stored embedding.

Jump to

Keyboard shortcuts

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