pub struct FakeTextResponse { /* private fields */ }Expand description
A fluent builder for a canned Step, for scripting what a
FakeProvider should return in a test.
§Example
use llmprism::testing::FakeTextResponse;
let step = FakeTextResponse::new("Hello!").build();
assert_eq!(step.text.as_deref(), Some("Hello!"));Implementations§
Source§impl FakeTextResponse
impl FakeTextResponse
Sourcepub fn new(text: impl Into<String>) -> Self
pub fn new(text: impl Into<String>) -> Self
Starts a canned response with the given reply text and a Stop finish
reason. Pass an empty string if you only want a tool call and no visible
text (see with_tool_call).
Sourcepub fn with_tool_call(
self,
id: impl Into<String>,
name: impl Into<String>,
arguments: Value,
) -> Self
pub fn with_tool_call( self, id: impl Into<String>, name: impl Into<String>, arguments: Value, ) -> Self
Scripts this response as also requesting a tool call, and switches the
finish reason to FinishReason::ToolCalls to match. Call this more than
once to script several tool calls in one round trip.
Sourcepub fn with_usage(self, usage: Usage) -> Self
pub fn with_usage(self, usage: Usage) -> Self
Overrides the token usage reported for this canned response, if your test needs to check usage accounting.
Sourcepub fn with_finish_reason(self, finish_reason: FinishReason) -> Self
pub fn with_finish_reason(self, finish_reason: FinishReason) -> Self
Overrides the finish reason, for testing how your application handles a
specific one (e.g. FinishReason::Length).
Trait Implementations§
Source§impl From<FakeTextResponse> for Step
impl From<FakeTextResponse> for Step
Source§fn from(fixture: FakeTextResponse) -> Self
fn from(fixture: FakeTextResponse) -> Self
Converts to this type from the input type.
Auto Trait Implementations§
impl Freeze for FakeTextResponse
impl RefUnwindSafe for FakeTextResponse
impl Send for FakeTextResponse
impl Sync for FakeTextResponse
impl Unpin for FakeTextResponse
impl UnsafeUnpin for FakeTextResponse
impl UnwindSafe for FakeTextResponse
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