pub struct CascadeEngine { /* private fields */ }Expand description
Multi-turn cascading inference engine.
Drives a model through a tool-call loop until a termination condition is met.
§Example
use std::sync::Arc;
use tokio_prompt_orchestrator::cascade::{CascadeEngine, CascadeConfig, NoopToolExecutor};
let engine = CascadeEngine::new(
Arc::new(|prompt: String| Box::pin(async move {
Ok(format!("Echo: {prompt}"))
})),
Arc::new(NoopToolExecutor),
);
let result = engine
.run("Summarise the Rust docs", &Default::default())
.await
.unwrap();
println!("Final answer: {}", result.final_answer);
println!("Turns taken: {}", result.turns.len());Implementations§
Source§impl CascadeEngine
impl CascadeEngine
Sourcepub fn new(infer_fn: InferFn, executor: Arc<dyn ToolExecutor>) -> Self
pub fn new(infer_fn: InferFn, executor: Arc<dyn ToolExecutor>) -> Self
Create a new engine with the given infer function and tool executor.
Sourcepub fn with_tool_parser(self, parser: Arc<dyn ToolCallParser>) -> Self
pub fn with_tool_parser(self, parser: Arc<dyn ToolCallParser>) -> Self
Override the default <tool_call> XML parser with a custom one.
Sourcepub async fn run(
&self,
prompt: &str,
config: &CascadeConfig,
) -> Result<CascadeResult, OrchestratorError>
pub async fn run( &self, prompt: &str, config: &CascadeConfig, ) -> Result<CascadeResult, OrchestratorError>
Run the cascade for the given prompt, returning all turns and the final answer.
§Errors
Returns an error only if the first inference call fails. Subsequent
failures are recorded in CascadeResult::termination_reason.
Auto Trait Implementations§
impl !RefUnwindSafe for CascadeEngine
impl !UnwindSafe for CascadeEngine
impl Freeze for CascadeEngine
impl Send for CascadeEngine
impl Sync for CascadeEngine
impl Unpin for CascadeEngine
impl UnsafeUnpin for CascadeEngine
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
§impl<T> FutureExt for T
impl<T> FutureExt for T
§fn with_context(self, otel_cx: Context) -> WithContext<Self>
fn with_context(self, otel_cx: Context) -> WithContext<Self>
§fn with_current_context(self) -> WithContext<Self>
fn with_current_context(self) -> WithContext<Self>
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
Wrap the input message
T in a tonic::Request