Documentation
¶
Overview ¶
Package rewrite implements the Layer B text rewrite hook (WR rewrite_text.py).
Index ¶
- Constants
- func BuildPrompt(strength, text, lang, originalLang string) string
- func CheckRemote(baseURL string, allowRemote bool) error
- func LexicalDivergence(original, candidate string) float64
- func NormalizeBackend(s string) (string, error)
- func NormalizeStrength(s string) (string, error)
- func SelectCandidate(original string, candidates []string) (string, []float64)
- type Options
- type Result
Constants ¶
View Source
const ( BackendPrintPrompt = "print-prompt" BackendOllama = "ollama" BackendOpenAI = "openai" // OpenAI-compatible /v1/chat/completions )
Backends.
View Source
const ( StrengthParaphrase = "paraphrase" StrengthHumanize = "humanize" StrengthCode = "code" StrengthBacktranslate = "backtranslate" StrengthStructural = "structural" )
Strengths.
Variables ¶
This section is empty.
Functions ¶
func BuildPrompt ¶
BuildPrompt builds the Layer B attack prompt (WR-compatible wording).
func CheckRemote ¶
CheckRemote enforces loopback-only endpoints unless AllowRemote.
func LexicalDivergence ¶
LexicalDivergence is bigram Jaccard distance: 0 identical, 1 fully different.
func NormalizeBackend ¶
NormalizeBackend maps aliases.
func NormalizeStrength ¶
NormalizeStrength maps aliases.
Types ¶
type Options ¶
type Options struct {
Backend string
Strength string
Model string
Endpoint string
APIKey string
Timeout time.Duration
Temperature float64
Candidates int
Lang string
OriginalLang string
AllowRemote bool
LayerAAfter bool
Aggressive bool // Layer A after: confusables
HTTPClient *http.Client
}
Options configure a single-file rewrite.
Click to show internal directories.
Click to hide internal directories.