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: ModelRefSelected model.
messages: Vec<Message>Ordered conversation messages.
tools: Vec<ToolSpec>Model-facing tools.
tool_choice: ToolChoiceTool-selection behavior.
output_format: OutputFormatDesired final-output format.
generation: GenerationOptionsCommon generation options.
feature_policy: FeaturePolicyFeature-degradation behavior.
provider_options: BTreeMap<String, Value>Typed adapters serialize options into their provider namespace.
metadata: ExtensionMapHost-only namespaced metadata.
Implementations§
Source§impl ModelRequest
impl ModelRequest
Sourcepub fn new(model: ModelRef, message: Message) -> Self
pub fn new(model: ModelRef, message: Message) -> Self
Creates a request with one initial message.
Sourcepub fn provider_tool(self, tool: ProviderToolSpec) -> Self
pub fn provider_tool(self, tool: ProviderToolSpec) -> Self
Adds a provider-hosted tool.
Sourcepub fn provider_tools(&self) -> Vec<ProviderToolSpec>
pub fn provider_tools(&self) -> Vec<ProviderToolSpec>
Returns provider-hosted tools separately from application function tools.
Sourcepub fn generation(self, generation: GenerationOptions) -> Self
pub fn generation(self, generation: GenerationOptions) -> Self
Replaces common generation controls.
Sourcepub fn response_mode(self, response_mode: ResponseMode) -> Self
pub fn response_mode(self, response_mode: ResponseMode) -> Self
Sets response delivery behavior.
Sourcepub fn selected_response_mode(&self) -> ResponseMode
pub fn selected_response_mode(&self) -> ResponseMode
Returns the requested response delivery mode.
Sourcepub fn provider_option(
self,
provider: impl Into<String>,
options: Value,
) -> Self
pub fn provider_option( self, provider: impl Into<String>, options: Value, ) -> Self
Adds an adapter-owned namespaced option object.
Sourcepub fn output_format(self, output_format: OutputFormat) -> Self
pub fn output_format(self, output_format: OutputFormat) -> Self
Sets the desired output format.
Sourcepub fn structured_output<T>(self, name: impl Into<String>) -> Selfwhere
T: JsonSchema,
pub fn structured_output<T>(self, name: impl Into<String>) -> Selfwhere
T: JsonSchema,
Requests strict structured output described by the Rust type T.
Sourcepub fn structured_output_with_strictness<T>(
self,
name: impl Into<String>,
strict: bool,
) -> Selfwhere
T: JsonSchema,
pub fn structured_output_with_strictness<T>(
self,
name: impl Into<String>,
strict: bool,
) -> Selfwhere
T: JsonSchema,
Requests structured output described by T with explicit provider
strictness.
Sourcepub const fn feature_policy(self, feature_policy: FeaturePolicy) -> Self
pub const fn feature_policy(self, feature_policy: FeaturePolicy) -> Self
Sets the feature-degradation policy.
Trait Implementations§
Source§impl Clone for ModelRequest
impl Clone for ModelRequest
Source§fn clone(&self) -> ModelRequest
fn clone(&self) -> ModelRequest
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more