struct MockRequest {
message: Option<String>,
conversation: Vec<String>,
format_name: Option<String>,
wants_json_object: bool,
stream: bool,
}Expand description
The parts of a request the mock picks its answer from.
Fields§
§message: Option<String>The text of the last input message, or None when the request ends in a tool output
instead. The other two endings never reach here.
conversation: Vec<String>Every message in the request, for recognising a round of a conversation whose latest message says nothing about which feature it belongs to.
format_name: Option<String>The structured output schema the answer has to parse as, None when none was named.
wants_json_object: boolWhether the caller asked for any valid JSON object instead of a named schema.
stream: boolWhether the caller reads the answer as a Server-Sent Events stream or as one JSON object.
Implementations§
Source§impl MockRequest
impl MockRequest
Sourcefn after_tool_run() -> Self
fn after_tool_run() -> Self
A streamed request resuming a tool loop, which ends in the tool’s output rather than in a message.
Sourcefn structured_output(format_name: &str) -> Self
fn structured_output(format_name: &str) -> Self
A request for structured output in format_name. Its message is one that would drive a
function call round if the message decided anything here, which it must not.
Sourcefn json_object(request_text: &str) -> Self
fn json_object(request_text: &str) -> Self
A request for any valid JSON object, whose conversation contains request_text.
Sourcefn wants_format(&self, format_name: &str) -> bool
fn wants_format(&self, format_name: &str) -> bool
Whether this asks for the structured output named format_name. False for a streamed
request even when it names the schema, since the answer to one is a whole JSON object that
a streaming caller cannot read.
Sourcefn wants_json_object_for(&self, request_text: &str) -> bool
fn wants_json_object_for(&self, request_text: &str) -> bool
Whether this asks for a JSON object and is part of a conversation that opened with
request_text. A JSON-mode request names no schema, so the feature it belongs to can only
be told from its prompt – and not from the latest message alone, which on a repair round is
the correction rather than the request.
Sourcefn prompt_section(&self, heading: &str, next_heading: &str) -> Option<&str>
fn prompt_section(&self, heading: &str, next_heading: &str) -> Option<&str>
The part of the prompt that heading introduces, ending where next_heading begins or at
the end of the message. None when no message in the conversation carries heading.
Reads the first message that has it: on a repair round the latest message is the correction rather than the request the headings belong to.
Sourcefn triggered_tool_call(&self) -> Option<TriggeredToolCall>
fn triggered_tool_call(&self) -> Option<TriggeredToolCall>
The tool call a streamed chat message asks the mock to make, if any.
Sourcefn message_contains(&self, trigger: &str) -> bool
fn message_contains(&self, trigger: &str) -> bool
Whether this is a streamed chat message containing trigger.
Auto Trait Implementations§
impl Freeze for MockRequest
impl RefUnwindSafe for MockRequest
impl Send for MockRequest
impl Sync for MockRequest
impl Unpin for MockRequest
impl UnsafeUnpin for MockRequest
impl UnwindSafe for MockRequest
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
§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> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::Request§impl<L> LayerExt<L> for L
impl<L> LayerExt<L> for L
§fn named_layer<S>(&self, service: S) -> Layered<<L as Layer<S>>::Service, S>where
L: Layer<S>,
fn named_layer<S>(&self, service: S) -> Layered<<L as Layer<S>>::Service, S>where
L: Layer<S>,
Layered].