Skip to main content

ChatModelConfig

Struct ChatModelConfig 

Source
#[non_exhaustive]
pub struct ChatModelConfig { /* private fields */ }
Expand description

Builder-side configuration that flows into every ModelRequest the ChatModel issues. Stored separately from the leaf service so layers / streaming / future surfaces share one source of truth.

Fields are private. Construct via ChatModelConfig::new; mutate through ChatModel’s with_* setters; inspect through the bare accessors on this type. #[non_exhaustive] plus the privatised fields together mean post-1.0 additions ship as MINOR without surprising any downstream consumer.

Implementations§

Source§

impl ChatModelConfig

Source

pub fn new(model: impl Into<String>) -> Self

Build a fresh config seeded with model and otherwise defaulted.

Source

pub fn token_counter(&self) -> Option<&Arc<dyn TokenCounter>>

Borrow the configured token counter, if any. Returns None when the operator has not wired one — pre-flight budget enforcement falls back to vendor Usage post-response.

Source

pub const fn validation_retries(&self) -> u32

complete_typed<O> retry budget. Default 0 — the first schema-mismatch fail surfaces unchanged. Operators that want the loop to reflect the parse error to the model and ask for a corrected JSON response set this to 13.

Source

pub fn model(&self) -> &str

Provider model identifier sent on the wire.

Source

pub const fn max_tokens(&self) -> Option<u32>

Per-call max_tokens cap (None = vendor default).

Source

pub const fn system(&self) -> &SystemPrompt

System-prompt blocks prepended to every call. Supports per-block prompt caching (Anthropic / Bedrock Converse).

Source

pub const fn temperature(&self) -> Option<f32>

Sampling temperature.

Source

pub const fn top_p(&self) -> Option<f32>

Nucleus-sampling parameter.

Source

pub const fn top_k(&self) -> Option<u32>

Top-k sampling parameter (None ⇒ vendor default). Codec support follows the IR mapping documented on crate::ir::ModelRequest::top_k.

Source

pub fn stop_sequences(&self) -> &[String]

Stop sequences.

Source

pub fn tools(&self) -> &[ToolSpec]

Advertised tools.

Source

pub const fn tool_choice(&self) -> &ToolChoice

Tool-choice mode.

Source

pub const fn reasoning_effort(&self) -> Option<&ReasoningEffort>

Cross-vendor reasoning-effort knob (None ⇒ vendor default). Codecs translate onto their native wire shape per the per-vendor mapping documented on crate::ir::ReasoningEffort; lossy approximations emit ModelWarning::LossyEncode.

Source

pub fn build_request(&self, messages: Vec<Message>) -> ModelRequest

Combine config with caller-supplied messages into a full ModelRequest. Only the fields the config carries are projected; per-request knobs and provider extensions stay at their Default (i.e. unset) and flow in via RequestOverrides or direct ExecutionContext::add_extension instead.

Trait Implementations§

Source§

impl Clone for ChatModelConfig

Source§

fn clone(&self) -> ChatModelConfig

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 ChatModelConfig

Source§

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

Formats the value using the given formatter. Read more

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> 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> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
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.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more