Skip to main content

CompletionOptions

Struct CompletionOptions 

Source
pub struct CompletionOptions<'a> {
    pub model: &'a str,
    pub max_tokens: Option<usize>,
    pub temperature: Option<f32>,
    pub timeout: Option<Duration>,
    pub stop_sequences: Vec<String>,
}
Expand description

Options for a completion request, passed to LlmProvider::complete_with_options.

Allows callers to supply per-request parameters (max tokens, temperature, timeout) in addition to the model name, without changing the base LlmProvider::complete signature.

Fields§

§model: &'a str

Model identifier (e.g. "claude-sonnet-4-6", "gpt-4o").

§max_tokens: Option<usize>

Maximum number of output tokens. Overrides provider defaults when set.

§temperature: Option<f32>

Sampling temperature in [0.0, 2.0]. Higher = more random.

§timeout: Option<Duration>

Per-request wall-clock timeout.

§stop_sequences: Vec<String>

Stop sequences: the model will stop generating when it produces any of these strings. An empty slice means no stop sequences.

Implementations§

Source§

impl<'a> CompletionOptions<'a>

Source

pub fn new(model: &'a str) -> Self

Create options with just a model name and all other fields unset.

Source

pub fn with_max_tokens(self, n: usize) -> Self

Set the maximum output tokens.

Source

pub fn with_temperature(self, t: f32) -> Self

Set the sampling temperature.

Source

pub fn with_timeout(self, d: Duration) -> Self

Set the per-request timeout.

Source

pub fn with_stop_sequences(self, sequences: Vec<String>) -> Self

Set stop sequences for this request.

Source

pub fn with_timeout_secs(self, secs: u64) -> Self

Set the per-request timeout from a number of seconds.

Source

pub fn with_timeout_ms(self, ms: u64) -> Self

Set the per-request timeout from a number of milliseconds.

Source

pub fn has_stop_sequences(&self) -> bool

Return true if at least one stop sequence has been configured.

Source

pub fn stop_sequence_count(&self) -> usize

Return the number of stop sequences configured.

Trait Implementations§

Source§

impl<'a> Debug for CompletionOptions<'a>

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<'a> Freeze for CompletionOptions<'a>

§

impl<'a> RefUnwindSafe for CompletionOptions<'a>

§

impl<'a> Send for CompletionOptions<'a>

§

impl<'a> Sync for CompletionOptions<'a>

§

impl<'a> Unpin for CompletionOptions<'a>

§

impl<'a> UnsafeUnpin for CompletionOptions<'a>

§

impl<'a> UnwindSafe for CompletionOptions<'a>

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

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

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

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

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.

§

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

§

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
§

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, 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.
§

impl<T> WithSubscriber for T

§

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
§

fn with_current_subscriber(self) -> WithDispatch<Self>

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