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

enrich

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Sep 11, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DescribeRequest

type DescribeRequest struct {
	Kind    string // "property" or "operation"
	Schema  string // owning schema name, e.g. "User"
	Name    string // property/field name, e.g. "createdAt"
	Snippet string // the added fragment (YAML) for type context
}

DescribeRequest is everything a provider needs to write one description. It is provider-agnostic: no vendor types leak in here.

type Enricher

type Enricher interface {
	Describe(ctx context.Context, req DescribeRequest) (string, error)
	Name() string // provider label, for logging/audit
}

Enricher writes a one-line, human-readable description for a new field or endpoint. One implementation per LLM provider (Anthropic, OpenAI, Gemini...). A returned error is non-fatal to the pipeline — the caller degrades.

type LLMEnricher

type LLMEnricher struct {
	Client llm.Client
}

LLMEnricher adapts any llm.Client into an Enricher. The DOMAIN knowledge — how to prompt for an OpenAPI description — lives here; the transport lives in the llm package. Swapping providers/fallback happens by passing a different llm.Client (e.g. llm.NewFallback(anthropic, openai)).

func NewLLMEnricher

func NewLLMEnricher(c llm.Client) *LLMEnricher

func (*LLMEnricher) Describe

func (l *LLMEnricher) Describe(ctx context.Context, req DescribeRequest) (string, error)

func (*LLMEnricher) Name

func (l *LLMEnricher) Name() string

type Result

type Result struct {
	Enriched int
	Skipped  int // patches that don't take a description (remove/replace/required)
	Failed   int // provider errored on these; description left empty
}

Result reports what happened, so failures are visible, never silent.

func Apply

func Apply(ctx context.Context, e Enricher, patches []patch.Patch) Result

Apply fills the Description slot on ADD patches only, in place. Everything the deterministic stage decided (op/path/value) is untouched — the LLM only adds prose. A provider failure leaves that one description empty and is counted, not propagated: partial success is the contract.

type StubEnricher

type StubEnricher struct{}

StubEnricher is a deterministic, offline provider for tests and demos.

func (StubEnricher) Describe

func (StubEnricher) Name

func (StubEnricher) Name() string

Jump to

Keyboard shortcuts

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