pub struct PromptOptimizer { /* private fields */ }Available on crate feature
eval only.Expand description
Iteratively improves an agent’s system instructions using an optimizer LLM and an evaluation set.
The optimizer runs a loop of evaluate → propose improvements → apply best →
repeat, logging progress via tracing at each iteration.
Implementations§
Source§impl PromptOptimizer
impl PromptOptimizer
Sourcepub fn new(
optimizer_llm: Arc<dyn Llm>,
evaluator: Evaluator,
config: OptimizerConfig,
) -> PromptOptimizer
pub fn new( optimizer_llm: Arc<dyn Llm>, evaluator: Evaluator, config: OptimizerConfig, ) -> PromptOptimizer
Create a new prompt optimizer.
§Arguments
optimizer_llm- The LLM used to propose instruction improvements (separate from the agent’s own LLM).evaluator- The evaluator used to score the agent against the eval set.config- Optimization configuration (max iterations, target threshold, output path).
Sourcepub async fn optimize(
&self,
agent: Arc<dyn Agent>,
eval_set: &EvalSet,
) -> Result<OptimizationResult, EvalError>
pub async fn optimize( &self, agent: Arc<dyn Agent>, eval_set: &EvalSet, ) -> Result<OptimizationResult, EvalError>
Run the optimization loop.
Evaluates the agent, proposes improvements via the optimizer LLM, applies the best improvement, and repeats until the target threshold is met or max iterations are exhausted.
On completion, writes the best-performing instructions to the configured output file.
Auto Trait Implementations§
impl Freeze for PromptOptimizer
impl !RefUnwindSafe for PromptOptimizer
impl Send for PromptOptimizer
impl Sync for PromptOptimizer
impl Unpin for PromptOptimizer
impl UnsafeUnpin for PromptOptimizer
impl !UnwindSafe for PromptOptimizer
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more