mock

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Apr 26, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package mock provides a deterministic llm.Provider implementation for tests. It does NOT require any network, API key, or external process. Callers import it directly (no build tag) — the package lives under internal/ so it cannot leak into the public API surface.

Index

Constants

View Source
const DefaultDims = 128

DefaultDims is the default embedding dimensionality.

Variables

This section is empty.

Functions

This section is empty.

Types

type Provider

type Provider struct {
	Dims int
}

Provider is a deterministic, in-memory llm.Provider useful for unit and integration tests. It inspects the prompt for known substrings and returns canned, schema-valid JSON; embeddings are derived from a SHA-256 of the input so equal text yields equal vectors.

func New

func New(dims int) *Provider

New returns a mock provider. Pass 0 for DefaultDims (128).

func (*Provider) BatchCeiling

func (p *Provider) BatchCeiling() int

func (*Provider) Complete

func (p *Provider) Complete(ctx context.Context, prompt string, _ ...llm.Option) (string, error)

Complete returns a deterministic response chosen by prompt substring. Schema must match what internal/extractor and internal/community expect; see entityPrompt in internal/extractor/entities.go and communityPrompt in internal/community/summarizer.go.

func (*Provider) Embed

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

Embed returns a Dims-length vector derived from SHA-256(text). Equal text yields equal vectors.

func (*Provider) EmbedBatch

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

func (*Provider) ModelID

func (p *Provider) ModelID() string

func (*Provider) Name

func (p *Provider) Name() string

Jump to

Keyboard shortcuts

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