Skip to main content

ModelRequest

Struct ModelRequest 

Source
pub struct ModelRequest {
    pub model: ModelRef,
    pub messages: Vec<Message>,
    pub tools: Vec<ToolSpec>,
    pub tool_choice: ToolChoice,
    pub output_format: OutputFormat,
    pub generation: GenerationOptions,
    pub feature_policy: FeaturePolicy,
    pub provider_options: BTreeMap<String, Value>,
    pub metadata: ExtensionMap,
}
Expand description

A complete provider-neutral model request.

Fields§

§model: ModelRef

Selected model.

§messages: Vec<Message>

Ordered conversation messages.

§tools: Vec<ToolSpec>

Model-facing tools.

§tool_choice: ToolChoice

Tool-selection behavior.

§output_format: OutputFormat

Desired final-output format.

§generation: GenerationOptions

Common generation options.

§feature_policy: FeaturePolicy

Feature-degradation behavior.

§provider_options: BTreeMap<String, Value>

Typed adapters serialize options into their provider namespace.

§metadata: ExtensionMap

Host-only namespaced metadata.

Implementations§

Source§

impl ModelRequest

Source

pub fn new(model: ModelRef, message: Message) -> Self

Creates a request with one initial message.

Source

pub fn message(self, message: Message) -> Self

Appends a conversation message.

Source

pub fn tool(self, tool: ToolSpec) -> Self

Adds a model-facing tool.

Source

pub fn provider_tool(self, tool: ProviderToolSpec) -> Self

Adds a provider-hosted tool.

Source

pub fn provider_tools(&self) -> Vec<ProviderToolSpec>

Returns provider-hosted tools separately from application function tools.

Source

pub fn generation(self, generation: GenerationOptions) -> Self

Replaces common generation controls.

Source

pub fn response_mode(self, response_mode: ResponseMode) -> Self

Sets response delivery behavior.

Source

pub fn selected_response_mode(&self) -> ResponseMode

Returns the requested response delivery mode.

Source

pub fn provider_option( self, provider: impl Into<String>, options: Value, ) -> Self

Adds an adapter-owned namespaced option object.

Source

pub fn output_format(self, output_format: OutputFormat) -> Self

Sets the desired output format.

Source

pub fn structured_output<T>(self, name: impl Into<String>) -> Self
where T: JsonSchema,

Requests strict structured output described by the Rust type T.

Source

pub const fn feature_policy(self, feature_policy: FeaturePolicy) -> Self

Sets the feature-degradation policy.

Trait Implementations§

Source§

impl Clone for ModelRequest

Source§

fn clone(&self) -> ModelRequest

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for ModelRequest

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'de> Deserialize<'de> for ModelRequest

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl PartialEq for ModelRequest

Source§

fn eq(&self, other: &ModelRequest) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl Serialize for ModelRequest

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl StructuralPartialEq for ModelRequest

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

impl<T> DynClone for T
where T: Clone,

Source§

fn __clone_box(&self, _: Private) -> *mut ()

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.