pub struct Program<'a, L: Llm, V: Validate> {
pub config: ProgramConfig,
/* private fields */
}Expand description
Program of Thought builder.
Generates code to solve problems, executes it, and refines if needed.
Fields§
§config: ProgramConfigConfiguration for Program of Thought.
Implementations§
Source§impl<'a, L: Llm> Program<'a, L, NoValidation>
impl<'a, L: Llm> Program<'a, L, NoValidation>
Source§impl<'a, L: Llm, V: Validate> Program<'a, L, V>
impl<'a, L: Llm, V: Validate> Program<'a, L, V>
Sourcepub fn validate<V2: Validate>(self, validator: V2) -> Program<'a, L, V2>
pub fn validate<V2: Validate>(self, validator: V2) -> Program<'a, L, V2>
Set a validator for the execution output.
Sourcepub fn executor<E: CodeExecutor + 'static>(self, executor: E) -> Self
pub fn executor<E: CodeExecutor + 'static>(self, executor: E) -> Self
Set the code executor.
This is required - without an executor, the code cannot be run.
Sourcepub fn executor_dyn(self, executor: Box<dyn DynCodeExecutor + 'static>) -> Self
pub fn executor_dyn(self, executor: Box<dyn DynCodeExecutor + 'static>) -> Self
Set a pre-boxed code executor (used by pipeline internals).
Sourcepub fn max_iter(self, n: u32) -> Self
pub fn max_iter(self, n: u32) -> Self
Set maximum code generation attempts.
If execution fails, the LLM will be asked to fix the code up to this many times.
Sourcepub fn language(self, lang: &str) -> Self
pub fn language(self, lang: &str) -> Self
Set the target programming language.
This is usually auto-detected from the executor but can be overridden.
Sourcepub fn extract(self, lang: impl Into<String>) -> Self
pub fn extract(self, lang: impl Into<String>) -> Self
Extract code blocks from execution output before validation.
When set, the validator receives extracted code from stdout rather
than the raw output. The result’s output field will also contain
the extracted code.
Sourcepub fn skill(self, skill: &Skill<'_>) -> Self
pub fn skill(self, skill: &Skill<'_>) -> Self
Attach a skill (persistent prompt context) to this builder.
Skill instructions are prepended to the code generation prompt.
Sourcepub fn defaults(self, defaults: Defaults) -> Self
pub fn defaults(self, defaults: Defaults) -> Self
Set runtime defaults applied via regex substitution before validation.
Defaults are applied to the execution output before validation.
Sourcepub fn go(self) -> ProgramResult
pub fn go(self) -> ProgramResult
Execute synchronously.
Sourcepub async fn run(self) -> ProgramResult
pub async fn run(self) -> ProgramResult
Execute asynchronously.
Auto Trait Implementations§
impl<'a, L, V> Freeze for Program<'a, L, V>where
V: Freeze,
impl<'a, L, V> !RefUnwindSafe for Program<'a, L, V>
impl<'a, L, V> Send for Program<'a, L, V>
impl<'a, L, V> Sync for Program<'a, L, V>
impl<'a, L, V> Unpin for Program<'a, L, V>where
V: Unpin,
impl<'a, L, V> UnsafeUnpin for Program<'a, L, V>where
V: UnsafeUnpin,
impl<'a, L, V> !UnwindSafe for Program<'a, L, V>
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
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more