Skip to main content

Program

Struct Program 

Source
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: ProgramConfig

Configuration for Program of Thought.

Implementations§

Source§

impl<'a, L: Llm> Program<'a, L, NoValidation>

Source

pub fn new(llm: &'a L, problem: &'a str) -> Self

Create a new Program of Thought builder.

Source§

impl<'a, L: Llm, V: Validate> Program<'a, L, V>

Source

pub fn validate<V2: Validate>(self, validator: V2) -> Program<'a, L, V2>

Set a validator for the execution output.

Source

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.

Source

pub fn executor_dyn(self, executor: Box<dyn DynCodeExecutor + 'static>) -> Self

Set a pre-boxed code executor (used by pipeline internals).

Source

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.

Source

pub fn language(self, lang: &str) -> Self

Set the target programming language.

This is usually auto-detected from the executor but can be overridden.

Source

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.

Source

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.

Source

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.

Source

pub fn no_code(self) -> Self

Disable code inclusion in result.

Source

pub fn go(self) -> ProgramResult

Execute synchronously.

Source

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> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.