pub struct StructuredOutputModel<M, T>where
M: Clone,{ /* private fields */ }Expand description
Wrapper for structured output from LLMs
Uses function calling to force the model to output JSON matching the schema of type T.
Trait Implementations§
Source§impl<M, T> ChatModel for StructuredOutputModel<M, T>
impl<M, T> ChatModel for StructuredOutputModel<M, T>
Source§fn invoke<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
messages: &'life1 [Message],
options: Option<&'life2 CallOptions>,
) -> Pin<Box<dyn Future<Output = Result<Message, LlmError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn invoke<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
messages: &'life1 [Message],
options: Option<&'life2 CallOptions>,
) -> Pin<Box<dyn Future<Output = Result<Message, LlmError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Invoke the model with messages Read more
Source§fn stream<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
messages: &'life1 [Message],
options: Option<&'life2 CallOptions>,
) -> Pin<Box<dyn Future<Output = Result<BoxStream<'_, Result<MessageChunk, LlmError>>, LlmError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn stream<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
messages: &'life1 [Message],
options: Option<&'life2 CallOptions>,
) -> Pin<Box<dyn Future<Output = Result<BoxStream<'_, Result<MessageChunk, LlmError>>, LlmError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Stream the model’s response Read more
Source§fn bind_tools(&self, tools: Vec<ToolDefinition>) -> Self
fn bind_tools(&self, tools: Vec<ToolDefinition>) -> Self
Bind tools to this model instance Read more
Source§fn with_structured_output<U: JsonSchema + DeserializeOwned + Serialize>(
self,
) -> StructuredOutputModel<Self, U>where
Self: Sized,
fn with_structured_output<U: JsonSchema + DeserializeOwned + Serialize>(
self,
) -> StructuredOutputModel<Self, U>where
Self: Sized,
Convert to structured output model Read more
Source§fn model_name(&self) -> &str
fn model_name(&self) -> &str
Get the model name
Source§impl<M: Clone, T> Clone for StructuredOutputModel<M, T>
impl<M: Clone, T> Clone for StructuredOutputModel<M, T>
Auto Trait Implementations§
impl<M, T> Freeze for StructuredOutputModel<M, T>where
M: Freeze,
impl<M, T> RefUnwindSafe for StructuredOutputModel<M, T>where
M: RefUnwindSafe,
T: RefUnwindSafe,
impl<M, T> Send for StructuredOutputModel<M, T>
impl<M, T> Sync for StructuredOutputModel<M, T>
impl<M, T> Unpin for StructuredOutputModel<M, T>
impl<M, T> UnsafeUnpin for StructuredOutputModel<M, T>where
M: UnsafeUnpin,
impl<M, T> UnwindSafe for StructuredOutputModel<M, T>where
M: 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