Skip to main content

ChatRequest

Struct ChatRequest 

Source
pub struct ChatRequest { /* private fields */ }
Expand description

Generates a chat completion. Build with Client::chat.

Implementations§

Source§

impl ChatRequest

Source

pub fn gpu(self, gpu: impl Into<String>) -> Self

Route to a machine profile, optionally pool-qualified as "pool/profile".

Source

pub fn wait_for_capacity(self, wait: bool) -> Self

Whether to wait out provisioning and model loading, or fail fast.

Source

pub fn provision_timeout(self, timeout: Duration) -> Self

Total wall-clock budget for this call, retries included.

Source

pub fn max_oom_retries(self, retries: u32) -> Self

Cap on RESOURCE_EXHAUSTED retries. Zero fails fast.

Source

pub fn max_completion_tokens(self, value: u32) -> Self

Cap on generated tokens. Prefer this over max_tokens.

Source

pub fn max_tokens(self, value: u32) -> Self

Legacy cap on generated tokens.

Source

pub fn temperature(self, value: f64) -> Self

Sampling temperature.

Source

pub fn top_p(self, value: f64) -> Self

Nucleus sampling cutoff.

Source

pub fn top_k(self, value: u32) -> Self

Sample only from the k most likely tokens.

Source

pub fn repetition_penalty(self, value: f64) -> Self

Penalty applied to repeated tokens.

Source

pub fn tools(self, value: Vec<Value>) -> Self

Tool definitions the model may call.

Source

pub fn tool_choice(self, value: Value) -> Self

Which tool the model must call, if any.

Source

pub fn parallel_tool_calls(self, value: bool) -> Self

Whether several tool calls may be issued at once.

Source

pub fn response_format(self, value: Value) -> Self

Structured output format.

Source

pub fn frequency_penalty(self, value: f64) -> Self

Penalty applied per prior occurrence of a token.

Source

pub fn presence_penalty(self, value: f64) -> Self

Penalty applied once a token has appeared at all.

Source

pub fn n(self, value: u32) -> Self

Number of candidates to return.

Source

pub fn best_of(self, value: u32) -> Self

Number of candidates to generate before picking. Incompatible with streaming.

Source

pub fn logprobs(self, value: bool) -> Self

Return per-token log probabilities.

Source

pub fn top_logprobs(self, value: u32) -> Self

How many alternatives to report per token, from 0 to 20.

Source

pub fn logit_bias(self, value: Value) -> Self

Per-token logit adjustments, each from -100 to 100.

Source

pub fn seed(self, value: i64) -> Self

Seed the sampler for reproducible output.

Source

pub fn stream_options(self, value: Value) -> Self

Stream tuning, such as {"include_usage": true}.

Source

pub fn user(self, value: impl Into<String>) -> Self

End-user identifier.

Source

pub fn safety_identifier(self, value: impl Into<String>) -> Self

End-user identifier forwarded to safety tooling.

Source

pub fn lora_adapter(self, value: impl Into<String>) -> Self

LoRA adapter to apply.

Source

pub fn stop(self, stop: impl IntoIterator<Item = impl Into<String>>) -> Self

Sequences that end the generation.

Source

pub fn extra_body(self, extra: Value) -> Self

Merge extra fields into the request body, overriding anything the builder set.

The gateway rejects unknown fields, so this is for options newer than the SDK.

Source

pub async fn send(self) -> Result<ChatCompletion>

Send the request and wait for the whole completion.

Source

pub async fn estimate(self) -> Result<CostEstimate>

Estimate what this request would cost.

Source§

impl ChatRequest

Source

pub fn stream(self) -> Result<ChunkStream<ChatCompletionChunk>>

Stream the completion token by token.

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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

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: Sized + 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: Sized + 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> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

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