pub struct ModelRequest {
pub messages: Vec<Message>,
pub system_prompt: Option<SystemPrompt>,
pub tool_specs: Vec<ToolSpec>,
pub tool_choice: Option<ToolChoice>,
pub model_state: StateStore,
pub dynamic_trailing_blocks: Option<usize>,
pub agent_metadata: Option<AgentMetadata>,
pub structured_output_schema: Option<JsonValue>,
pub cancel_signal: Option<CancelSignal>,
pub deferred_tools: HashSet<String>,
}Expand description
One request to a model: the conversation and its options.
The request is owned, so a provider can move it into a spawned task.
Fields§
§messages: Vec<Message>The conversation to send.
system_prompt: Option<SystemPrompt>System prompt guiding the model’s behavior.
tool_specs: Vec<ToolSpec>Tools the model may call.
tool_choice: Option<ToolChoice>How the model selects tools.
model_state: StateStoreState for providers that keep conversation state server-side, such as a response id for chaining. The agent passes a copy and keeps the provider’s changes only when the call succeeds.
dynamic_trailing_blocks: Option<usize>How many trailing blocks of the last user message are rebuilt on every call.
agent_metadata: Option<AgentMetadata>Metadata of the invoking agent.
structured_output_schema: Option<JsonValue>JSON schema this call must produce, set by the agent on its structured output retry. The
response must then call the tool named in tool_choice, or be a final text response that is
exactly one JSON object valid against this schema.
cancel_signal: Option<CancelSignal>Signal a provider can forward to abort the in-flight request. Support is provider-dependent.
deferred_tools: HashSet<String>Names of the tools in tool_specs this call defers; empty when it defers none. A provider
whose model defers tools natively (ModelCapabilities::deferred_tool_loading is
DeferredToolLoading::Native) keeps their input
schemas out of the model’s context until the model loads them; every other provider
ignores it.
Implementations§
Source§impl ModelRequest
impl ModelRequest
Sourcepub fn builder() -> ModelRequestBuilder
pub fn builder() -> ModelRequestBuilder
Create an instance of ModelRequest using the builder syntax
Trait Implementations§
Source§impl Clone for ModelRequest
impl Clone for ModelRequest
Source§impl Debug for ModelRequest
impl Debug for ModelRequest
Auto Trait Implementations§
impl !RefUnwindSafe for ModelRequest
impl !UnwindSafe for ModelRequest
impl Freeze for ModelRequest
impl Send for ModelRequest
impl Sync for ModelRequest
impl Unpin for ModelRequest
impl UnsafeUnpin for ModelRequest
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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§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