pub struct StructuredChatBuilder<T, H: RetryHandler = DefaultRetryHandler> { /* private fields */ }Available on crate feature
client only.Expand description
Builder for structured output chat requests.
Created via [ChatRequestBuilder::structured()].
Implementations§
Source§impl<T: JsonSchema + DeserializeOwned> StructuredChatBuilder<T, DefaultRetryHandler>
impl<T: JsonSchema + DeserializeOwned> StructuredChatBuilder<T, DefaultRetryHandler>
Sourcepub fn new(inner: ChatRequestBuilder) -> Self
pub fn new(inner: ChatRequestBuilder) -> Self
Create a new structured builder from a chat request builder.
Source§impl<T: JsonSchema + DeserializeOwned, H: RetryHandler> StructuredChatBuilder<T, H>
impl<T: JsonSchema + DeserializeOwned, H: RetryHandler> StructuredChatBuilder<T, H>
Sourcepub fn max_retries(self, retries: u32) -> Self
pub fn max_retries(self, retries: u32) -> Self
Set the maximum number of retries on validation failure.
Sourcepub fn retry_handler<H2: RetryHandler>(
self,
handler: H2,
) -> StructuredChatBuilder<T, H2>
pub fn retry_handler<H2: RetryHandler>( self, handler: H2, ) -> StructuredChatBuilder<T, H2>
Set a custom retry handler.
Sourcepub fn schema_name(self, name: impl Into<String>) -> Self
pub fn schema_name(self, name: impl Into<String>) -> Self
Override the schema name.
Sourcepub fn max_tokens(self, max_tokens: i64) -> Self
pub fn max_tokens(self, max_tokens: i64) -> Self
Set max tokens.
Sourcepub fn temperature(self, temperature: f64) -> Self
pub fn temperature(self, temperature: f64) -> Self
Set temperature.
Sourcepub async fn send(
self,
client: &LLMClient,
) -> Result<StructuredResult<T>, StructuredError>
pub async fn send( self, client: &LLMClient, ) -> Result<StructuredResult<T>, StructuredError>
Execute the structured request (blocking, async).
Returns a typed result with validation retries if configured.
Sourcepub async fn stream(
self,
client: &LLMClient,
) -> Result<StructuredJSONStream<T>, StructuredError>
Available on crate feature streaming only.
pub async fn stream( self, client: &LLMClient, ) -> Result<StructuredJSONStream<T>, StructuredError>
streaming only.Execute and stream structured responses.
Note: Streaming does not support retries. For retry behavior, use [send].
Auto Trait Implementations§
impl<T, H> Freeze for StructuredChatBuilder<T, H>where
H: Freeze,
impl<T, H> RefUnwindSafe for StructuredChatBuilder<T, H>where
H: RefUnwindSafe,
T: RefUnwindSafe,
impl<T, H> Send for StructuredChatBuilder<T, H>where
T: Send,
impl<T, H> Sync for StructuredChatBuilder<T, H>where
T: Sync,
impl<T, H> Unpin for StructuredChatBuilder<T, H>
impl<T, H> UnwindSafe for StructuredChatBuilder<T, H>where
H: UnwindSafe,
T: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more