Documentation
¶
Overview ¶
Package llmcorrect implements a language-model-based transcript correction stage that resolves entity misspellings not caught by the phonetic matcher.
The Corrector sends the raw transcript text to an llm.Provider along with the list of known entity names. The model is instructed (via a conservative system prompt) to fix only words that look like misspelled entity names and to return a structured JSON response containing the corrected text and an itemised list of substitutions.
This stage runs exclusively in the background — never on the real-time voice path — so the small latency penalty (100–200 ms) is acceptable. When the LLM response cannot be parsed, the corrector returns the original text unchanged rather than surfacing an error, ensuring pipeline robustness.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Correction ¶
type Correction struct {
// Original is the word as it appeared in the input transcript.
Original string
// Corrected is the replacement entity name suggested by the LLM.
Corrected string
// Confidence is the LLM's reported confidence for this substitution (0.0–1.0).
Confidence float64
}
Correction captures a single word-level substitution produced by the LLM corrector. The pipeline maps these to [transcript.Correction] values with Method set to "llm".
type Corrector ¶
type Corrector struct {
// contains filtered or unexported fields
}
Corrector uses an llm.Provider to correct entity name misspellings in transcript text. It is safe for concurrent use.
Model selection follows the one-provider-per-model pattern: to use a specific model for correction, construct the llm.Provider with that model configured, rather than overriding per-request.
func New ¶
New returns a new Corrector backed by the given llm.Provider. Apply Option values to override the default temperature or model.
func (*Corrector) Correct ¶
func (c *Corrector) Correct( ctx context.Context, text string, entities []string, lowConfidenceSpans []string, ) (string, []Correction, error)
Correct sends text to the LLM with the entity list as context and asks it to fix entity name misspellings. lowConfidenceSpans are highlighted in the user message as candidate spans that may be misheard.
When the LLM response is unparseable, Correct returns the original text unchanged with a nil corrections slice and a nil error (graceful degradation — the pipeline must continue).
Context cancellation and network errors are returned as non-nil errors.