Documentation
¶
Overview ¶
Package rewriter provides LLM prompt rewriter middleware (master plan §6.x). The rewriter strips politeness filler, injects specificity hints, and classifies prompt complexity. It is wired through the agent's PromptRewriter interface and instantiated by the API layer when the rewriter config section is present. Not enabled by default; opt-in via config (see RewriterConfig).
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AnalysisResult ¶
type Complexity ¶
type Complexity int
const ( ComplexitySimple Complexity = iota ComplexityAmbiguous Complexity = iota ComplexityComplex Complexity = iota )
func (Complexity) String ¶
func (c Complexity) String() string
type LLMRewriter ¶
type LLMRewriter struct {
// contains filtered or unexported fields
}
func NewConfiguredRewriter ¶
func NewConfiguredRewriter(provider providers.Provider, fallbackModel string, cfg config.RewriterConfig) *LLMRewriter
NewConfiguredRewriter is the shared CLI/API config mapping. In particular, enabling the middleware alone does not opt into paid provider calls.
func NewLLMRewriter ¶
func NewLLMRewriter(provider providers.Provider, model string) *LLMRewriter
func NewWithOptions ¶
func NewWithOptions(provider providers.Provider, model string, opts Options) *LLMRewriter
func (*LLMRewriter) Rewrite ¶
func (r *LLMRewriter) Rewrite(ctx context.Context, input string) (*RewriteResult, error)
func (*LLMRewriter) RewritePrompt ¶
RewritePrompt is a thin convenience wrapper around Rewrite that returns just the rewritten string, suitable for middleware-style use. Falls back to the original input on error so a misbehaving rewriter never blocks the agent.
type Middleware ¶
type Middleware struct {
// contains filtered or unexported fields
}
func NewMiddleware ¶
func NewMiddleware() *Middleware
func (*Middleware) Analyze ¶
func (m *Middleware) Analyze(input string) *AnalysisResult
func (*Middleware) InjectSpecificity ¶
func (m *Middleware) InjectSpecificity(input string) (string, []string)
type Options ¶
Options independently controls local and provider-assisted transformations. A disabled rewriter is an exact passthrough, including whitespace.
type RewriteResult ¶
type Rewriter ¶
type Rewriter interface {
Rewrite(ctx context.Context, input string) (*RewriteResult, error)
}
type SycophancyReducer ¶
type SycophancyReducer struct {
// contains filtered or unexported fields
}
func NewSycophancyReducer ¶
func NewSycophancyReducer() *SycophancyReducer
func (*SycophancyReducer) Check ¶
func (s *SycophancyReducer) Check(response string) *SycophancyReport
func (*SycophancyReducer) Strip ¶
func (s *SycophancyReducer) Strip(response string) string