Documentation
¶
Overview ¶
Package rewrite is the optional Layer 2 pass. It hands text to a model to do what the deterministic rules cannot, like reworking a sentence to drop a semicolon or bending the text toward a chosen voice.
Index ¶
Constants ¶
const ( // DefaultOpenAIModel is the model used for --provider openai when none is set. DefaultOpenAIModel = "gpt-4o" // DefaultOpenAIBaseURL is the OpenAI Chat Completions base. Any OpenAI-compatible // server, like a local Ollama or a router, is reached by overriding it. DefaultOpenAIBaseURL = "https://api.openai.com/v1" )
OpenAI-compatible Chat Completions constants.
const DefaultModel = "claude-opus-4-8"
DefaultModel is the model used when none is set.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Completer ¶
Completer sends a system prompt and a user prompt to a model and returns the text of the reply.
func NewAnthropicCompleter ¶
NewAnthropicCompleter returns a Completer that calls the Anthropic Messages API over HTTP. It reads the API key from the ANTHROPIC_API_KEY environment variable. Talking to the API directly keeps the deterministic core free of the Anthropic SDK and its dependency tree, so the default binary stays small.
func NewCompleter ¶ added in v0.10.0
NewCompleter returns the Completer for provider. model and baseURL may be empty, in which case the provider's own defaults stand. baseURL only applies to the OpenAI provider. An unknown provider is an error.
func NewOpenAICompleter ¶ added in v0.10.0
NewOpenAICompleter returns a Completer that calls an OpenAI-compatible Chat Completions API. It reads the API key from OPENAI_API_KEY. An empty model or base URL falls back to the OpenAI defaults. A local base URL may run without a key, since servers like Ollama ignore the Authorization header.
type CompleterFunc ¶
CompleterFunc adapts a function to the Completer interface.
type Issue ¶ added in v0.7.0
type Issue struct {
// Kind is added, removed, or changed.
Kind string `json:"kind"`
// Was is the original wording, empty when the rewrite added something.
Was string `json:"was"`
// Now is the rewrite wording, empty when the rewrite removed something.
Now string `json:"now"`
// Note is a short reason for the issue.
Note string `json:"note"`
}
Issue is one meaning change between the original and the rewrite.
type Judge ¶ added in v0.7.0
type Judge struct {
// contains filtered or unexported fields
}
Judge compares an original text with its rewrite through a Completer and reports any change in meaning. It is the optional Layer 3 pass behind the --verify flag.
type Provider ¶ added in v0.10.0
type Provider string
Provider names a model backend the rewrite pass can talk to.
type Rewriter ¶
type Rewriter struct {
// contains filtered or unexported fields
}
Rewriter rewrites text through a Completer using a built system prompt.
type Verdict ¶ added in v0.7.0
type Verdict struct {
// Faithful reports whether the rewrite preserved the original's meaning.
Faithful bool `json:"faithful"`
// Issues lists each meaning change the judge found.
Issues []Issue `json:"issues"`
}
Verdict is the meaning-comparison result from the judge.