pub struct TypedResponse<R> { /* private fields */ }Expand description
Typed structured-response description for one completion call.
use agents::response::TypedResponse;
use schemars::JsonSchema;
use serde::{Deserialize, Serialize};
#[derive(Clone, Debug, Serialize, Deserialize, JsonSchema)]
struct Answer {
text: String,
}
let format = TypedResponse::<Answer>::new("answer");
let raw = format.to_raw_response_format();
assert_eq!(raw.r#type, "json_schema");
assert!(raw.json_schema.is_some());Implementations§
Source§impl<R> TypedResponse<R>where
R: JsonSchema,
impl<R> TypedResponse<R>where
R: JsonSchema,
Sourcepub fn with_strict(self, strict: bool) -> Self
pub fn with_strict(self, strict: bool) -> Self
Controls whether providers should enforce the schema strictly when supported.
Sourcepub fn to_raw_response_format(&self) -> RawResponseFormat
pub fn to_raw_response_format(&self) -> RawResponseFormat
Converts the typed schema into the raw provider-facing payload.
Trait Implementations§
Source§impl<R: Clone> Clone for TypedResponse<R>
impl<R: Clone> Clone for TypedResponse<R>
Source§fn clone(&self) -> TypedResponse<R>
fn clone(&self) -> TypedResponse<R>
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl<R> Freeze for TypedResponse<R>
impl<R> RefUnwindSafe for TypedResponse<R>where
R: RefUnwindSafe,
impl<R> Send for TypedResponse<R>where
R: Send,
impl<R> Sync for TypedResponse<R>where
R: Sync,
impl<R> Unpin for TypedResponse<R>where
R: Unpin,
impl<R> UnsafeUnpin for TypedResponse<R>
impl<R> UnwindSafe for TypedResponse<R>where
R: 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