pub struct ScriptedModel { /* private fields */ }Expand description
Replays queued responses in order and streams each response’s text as one
delta. An exhausted script fails the request with a decode-style
LlmError so a test never hangs on a missing response.
Implementations§
Source§impl ScriptedModel
impl ScriptedModel
Sourcepub fn new(
responses: impl IntoIterator<Item = Result<CompletionResponse, LlmError>>,
) -> Self
pub fn new( responses: impl IntoIterator<Item = Result<CompletionResponse, LlmError>>, ) -> Self
Model that replays responses in order.
Sourcepub fn replies(messages: impl IntoIterator<Item = ChatMessage>) -> Self
pub fn replies(messages: impl IntoIterator<Item = ChatMessage>) -> Self
Script one assistant reply per message, each finishing with stop (or
tool_calls when the message carries tool calls).
Sourcepub fn response(message: ChatMessage) -> CompletionResponse
pub fn response(message: ChatMessage) -> CompletionResponse
Build a canonical single-choice response for message.
Sourcepub fn requests(&self) -> Vec<CompletionRequest>
pub fn requests(&self) -> Vec<CompletionRequest>
Every request the runtime sent, in order.
Trait Implementations§
Source§impl ChatModel for ScriptedModel
impl ChatModel for ScriptedModel
Source§fn complete_streaming<'life0, 'life1, 'async_trait>(
&'life0 self,
request: &'life1 CompletionRequest,
delta_tx: UnboundedSender<(String, bool)>,
) -> Pin<Box<dyn Future<Output = Result<CompletionResponse, LlmError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn complete_streaming<'life0, 'life1, 'async_trait>(
&'life0 self,
request: &'life1 CompletionRequest,
delta_tx: UnboundedSender<(String, bool)>,
) -> Pin<Box<dyn Future<Output = Result<CompletionResponse, LlmError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Stream cumulative
(content, has_tool_calls) updates and return the
canonical terminal response. This is the only model invocation path.Source§impl Default for ScriptedModel
impl Default for ScriptedModel
Source§fn default() -> ScriptedModel
fn default() -> ScriptedModel
Returns the “default value” for a type. Read more
Auto Trait Implementations§
impl !Freeze for ScriptedModel
impl RefUnwindSafe for ScriptedModel
impl Send for ScriptedModel
impl Sync for ScriptedModel
impl Unpin for ScriptedModel
impl UnsafeUnpin for ScriptedModel
impl UnwindSafe for ScriptedModel
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