pub trait TurnGenerator: Send + Sync {
// Required method
fn generate<'life0, 'async_trait>(
&'life0 self,
req: GenerateRequest,
) -> Pin<Box<dyn Future<Output = Result<InferenceResult, String>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
// Provided methods
fn generate_coder<'life0, 'async_trait>(
&'life0 self,
req: GenerateRequest,
) -> Pin<Box<dyn Future<Output = Result<InferenceResult, TurnGenerationError>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait { ... }
fn generate_coder_observed<'life0, 'life1, 'async_trait>(
&'life0 self,
req: GenerateRequest,
_retry_observer: &'life1 mut (dyn FnMut(InferenceRetryProgress) + Send),
) -> Pin<Box<dyn Future<Output = Result<InferenceResult, TurnGenerationError>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait { ... }
fn generate_assistant<'life0, 'async_trait>(
&'life0 self,
req: GenerateRequest,
) -> Pin<Box<dyn Future<Output = Result<InferenceResult, AssistantGenerateError>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait { ... }
fn generate_assistant_observed<'life0, 'life1, 'async_trait>(
&'life0 self,
req: GenerateRequest,
_retry_observer: &'life1 mut (dyn FnMut(InferenceRetryProgress) + Send),
) -> Pin<Box<dyn Future<Output = Result<InferenceResult, AssistantGenerateError>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait { ... }
fn context_window(&self, _model: &str) -> usize { ... }
}Required Methods§
fn generate<'life0, 'async_trait>(
&'life0 self,
req: GenerateRequest,
) -> Pin<Box<dyn Future<Output = Result<InferenceResult, String>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Provided Methods§
Sourcefn generate_coder<'life0, 'async_trait>(
&'life0 self,
req: GenerateRequest,
) -> Pin<Box<dyn Future<Output = Result<InferenceResult, TurnGenerationError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn generate_coder<'life0, 'async_trait>(
&'life0 self,
req: GenerateRequest,
) -> Pin<Box<dyn Future<Output = Result<InferenceResult, TurnGenerationError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Coder-specific generation keeps routing exhaustion typed so an unattended caller can classify configuration failures without parsing error prose. Other consumers retain the original string seam.
fn generate_coder_observed<'life0, 'life1, 'async_trait>(
&'life0 self,
req: GenerateRequest,
_retry_observer: &'life1 mut (dyn FnMut(InferenceRetryProgress) + Send),
) -> Pin<Box<dyn Future<Output = Result<InferenceResult, TurnGenerationError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Sourcefn generate_assistant<'life0, 'async_trait>(
&'life0 self,
req: GenerateRequest,
) -> Pin<Box<dyn Future<Output = Result<InferenceResult, AssistantGenerateError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn generate_assistant<'life0, 'async_trait>(
&'life0 self,
req: GenerateRequest,
) -> Pin<Box<dyn Future<Output = Result<InferenceResult, AssistantGenerateError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Assistant-specific generation: keeps the failures a chat turn can END on
typed, so the loop can answer with a remedy instead of
inference failed: <prose>.
The default body delegates to TurnGenerator::generate and buckets
the string as Other, so every existing implementor — production,
harness, and every dyn TurnGenerator site — inherits it unchanged and
no test double has to be rewritten to keep compiling.
Sourcefn generate_assistant_observed<'life0, 'life1, 'async_trait>(
&'life0 self,
req: GenerateRequest,
_retry_observer: &'life1 mut (dyn FnMut(InferenceRetryProgress) + Send),
) -> Pin<Box<dyn Future<Output = Result<InferenceResult, AssistantGenerateError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn generate_assistant_observed<'life0, 'life1, 'async_trait>(
&'life0 self,
req: GenerateRequest,
_retry_observer: &'life1 mut (dyn FnMut(InferenceRetryProgress) + Send),
) -> Pin<Box<dyn Future<Output = Result<InferenceResult, AssistantGenerateError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Assistant generation with observable provider retries. Implementors that do not retry inherit the ordinary one-call path.
Sourcefn context_window(&self, _model: &str) -> usize
fn context_window(&self, _model: &str) -> usize
The context window (in tokens) of the model this generator drives, or
0 when unknown. Multi-turn drivers use it to bound their running
message history before it overflows the window. Defaults to 0 so
test doubles need not implement it (the loop then skips compaction).
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".