llm

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Oct 6, 2026 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Overview

Package llm implements FR-MCP-05's optional BYO-LLM narrative layer: turning a diagnose.Findings into a short plain-English explanation by calling a user-configured LLM endpoint. It is entirely stdlib (net/http + encoding/json) — no SDK, no new go.mod dependency — and entirely opt-in: per NFR-05 ("nothing leaves the local machine unless explicitly configured"), ConfigFromEnv returns a Config with an empty Provider when nothing is set, and Narrate treats that as "do not make a network call" rather than an error.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Narrate

func Narrate(ctx context.Context, cfg Config, prompt string) (string, error)

Narrate turns prompt — already-composed text describing a run's diagnose.Findings, built by the caller so this package stays prompt-content-agnostic — into a short natural-language explanation via cfg's configured provider. It returns ("", nil) without making any network call when cfg is not Enabled(), which is the expected path whenever the user hasn't opted in.

Types

type Config

type Config struct {
	Provider string // "openai", "ollama", "anthropic", or "" (disabled)
	APIKey   string
	BaseURL  string
	Model    string
}

Config holds everything Narrate needs to call an LLM endpoint. Every field comes from an environment variable (see ConfigFromEnv) so that neither the CLI nor the MCP layer has to grow its own provider flags — both just call Narrate and let the user's shell environment decide whether it does anything at all.

func ConfigFromEnv

func ConfigFromEnv() Config

ConfigFromEnv reads VEGALOAD_LLM_PROVIDER, VEGALOAD_LLM_API_KEY, VEGALOAD_LLM_BASE_URL, and VEGALOAD_LLM_MODEL. Only Provider is required to enable narration — ollama commonly needs no API key, and each provider has a sensible BaseURL/Model default (see defaults.go equivalents below) so a user who only sets the provider still gets a working call.

func (Config) Enabled

func (c Config) Enabled() bool

Enabled reports whether cfg has enough set to attempt a call. An empty Provider is the documented way to disable narration entirely.

Jump to

Keyboard shortcuts

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