Documentation
¶
Overview ¶
Package prompt provides prompt-construction and prompt-optimisation types.
Index ¶
- func ComputeGradientPrompt(paramName, currentValue, feedback string, examples []string) string
- func FormatPromptExamples(examples []PromptExample) string
- func OptimizePrompt(ctx context.Context, llm LLMClient, model string, po *PromptOptimizer, ...) (string, error)
- type ABTest
- type DSPyExample
- type DSPyVariant
- type LLMClient
- type OptimizationStep
- type Optimizer
- type PromptExample
- type PromptFewShotSelector
- type PromptGradient
- type PromptOptimizer
- func (po *PromptOptimizer) ApplyGradient(paramName, newValue string, gradient PromptGradient)
- func (po *PromptOptimizer) Get(name string) string
- func (po *PromptOptimizer) NeedsOptimization(threshold float64) []*PromptParameter
- func (po *PromptOptimizer) RecordFailure(paramName, feedback string)
- func (po *PromptOptimizer) RecordSuccess(paramName string)
- func (po *PromptOptimizer) Register(name, initialValue string)
- type PromptParameter
- type PromptTuner
- type PromptVariant
- type Tuner
- type Variant
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ComputeGradientPrompt ¶
func FormatPromptExamples ¶
func FormatPromptExamples(examples []PromptExample) string
func OptimizePrompt ¶
Types ¶
type ABTest ¶
type ABTest struct {
A, B DSPyVariant
}
ABTest pits two prompt variants against each other on incoming traffic.
func NewABTest ¶
func NewABTest(a, b DSPyVariant) *ABTest
NewABTest builds an A/B test between two variants.
type DSPyExample ¶
type DSPyExample = PromptExample
DSPyExample is one (input, output) demonstration backing the optimizer.
type DSPyVariant ¶
type DSPyVariant = PromptVariant
DSPyVariant is a candidate prompt being evaluated.
type LLMClient ¶
type LLMClient interface {
Chat(ctx context.Context, msgs []types.EyrieMessage, opts types.ChatOptions) (*types.EyrieResponse, error)
}
LLMClient is the minimal interface needed for prompt optimization.
type OptimizationStep ¶
type Optimizer ¶
type Optimizer = PromptOptimizer
Optimizer learns better prompts via DSPy-style example mining.
type PromptExample ¶
type PromptFewShotSelector ¶
type PromptFewShotSelector struct {
Examples []PromptExample
}
func (*PromptFewShotSelector) Select ¶
func (fs *PromptFewShotSelector) Select(query string, k int) []PromptExample
type PromptGradient ¶
type PromptOptimizer ¶
type PromptOptimizer struct {
Parameters map[string]*PromptParameter
History []OptimizationStep
Path string
}
func NewPromptOptimizer ¶
func NewPromptOptimizer() *PromptOptimizer
func (*PromptOptimizer) ApplyGradient ¶
func (po *PromptOptimizer) ApplyGradient(paramName, newValue string, gradient PromptGradient)
func (*PromptOptimizer) Get ¶
func (po *PromptOptimizer) Get(name string) string
func (*PromptOptimizer) NeedsOptimization ¶
func (po *PromptOptimizer) NeedsOptimization(threshold float64) []*PromptParameter
func (*PromptOptimizer) RecordFailure ¶
func (po *PromptOptimizer) RecordFailure(paramName, feedback string)
func (*PromptOptimizer) RecordSuccess ¶
func (po *PromptOptimizer) RecordSuccess(paramName string)
func (*PromptOptimizer) Register ¶
func (po *PromptOptimizer) Register(name, initialValue string)
type PromptParameter ¶
type PromptTuner ¶
type PromptTuner struct {
// contains filtered or unexported fields
}
func NewPromptTuner ¶
func NewPromptTuner() *PromptTuner
func (*PromptTuner) BestVariant ¶
func (pt *PromptTuner) BestVariant(section string) (string, float64)
func (*PromptTuner) RecordOutcome ¶
func (pt *PromptTuner) RecordOutcome(section, content string, success bool)
func (*PromptTuner) Report ¶
func (pt *PromptTuner) Report() string
type PromptVariant ¶
type Tuner ¶
type Tuner = PromptTuner
Tuner is a lighter-weight prompt-tuning helper for online adjustments.
Click to show internal directories.
Click to hide internal directories.