pub struct ScriptedLlm { /* private fields */ }Expand description
A deterministic LLM double with pre-scripted responses.
ScriptedLlm implements the real Llm trait and exercises the full
runtime pipeline. Only the provider API call is replaced — everything else
(session loop, checkpoints, parking, event mapping) runs exactly as it would
with a real provider.
This is explicitly NOT a mock. It:
- Implements the full
Llmtrait contract - Returns complete
LlmResponseobjects with properContentandParttypes - Supports tool calls (function calls) in responses
- Advances through turns deterministically (FIFO order)
- Is thread-safe (
Send + SyncviaAtomicUsize)
§Panics
If more turns are requested than were scripted, the LLM returns an empty
response with turn_complete = true rather than panicking.
Implementations§
Source§impl ScriptedLlm
impl ScriptedLlm
Sourcepub fn new(name: impl Into<String>, turns: Vec<ScriptedTurn>) -> Self
pub fn new(name: impl Into<String>, turns: Vec<ScriptedTurn>) -> Self
Create a new ScriptedLlm with the given name and pre-scripted turns.
Turns are consumed in FIFO order — each call to generate_content
advances to the next turn.
Sourcepub fn turns_consumed(&self) -> usize
pub fn turns_consumed(&self) -> usize
Returns the number of turns that have been consumed so far.
Sourcepub fn total_turns(&self) -> usize
pub fn total_turns(&self) -> usize
Returns the total number of scripted turns.
Trait Implementations§
Source§impl Debug for ScriptedLlm
impl Debug for ScriptedLlm
Source§impl Llm for ScriptedLlm
impl Llm for ScriptedLlm
Source§fn generate_content<'life0, 'async_trait>(
&'life0 self,
_request: LlmRequest,
_stream: bool,
) -> Pin<Box<dyn Future<Output = AdkResult<LlmResponseStream>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn generate_content<'life0, 'async_trait>(
&'life0 self,
_request: LlmRequest,
_stream: bool,
) -> Pin<Box<dyn Future<Output = AdkResult<LlmResponseStream>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Generates content from the given request, optionally streaming.
Source§fn schema_adapter(&self) -> &dyn SchemaAdapter
fn schema_adapter(&self) -> &dyn SchemaAdapter
Returns the schema adapter for this provider. Read more
Source§fn uses_interactions_api(&self) -> bool
fn uses_interactions_api(&self) -> bool
Returns
true if this model is configured to use a server-managed
environment (e.g., Gemini Interactions API) where the provider owns
the tool-calling loop and filesystem. Read moreAuto Trait Implementations§
impl !Freeze for ScriptedLlm
impl RefUnwindSafe for ScriptedLlm
impl Send for ScriptedLlm
impl Sync for ScriptedLlm
impl Unpin for ScriptedLlm
impl UnsafeUnpin for ScriptedLlm
impl UnwindSafe for ScriptedLlm
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