pub trait OutputHandler<O>:
Send
+ Sync
+ 'static {
// Required methods
fn response_format(&self) -> Option<ResponseFormat>;
fn parse_complete(
&self,
text: &str,
ctx: &OutputContext,
) -> Result<O, Error>;
fn parse_partial(&self, text: &str) -> Option<JsonValue>;
// Provided methods
fn wants_output(&self) -> bool { ... }
fn typed_partial(&self, _value: &JsonValue) -> Option<O> { ... }
fn parse_elements(&self, _text: &str) -> Option<Vec<JsonValue>> { ... }
}Expand description
Implements an output strategy for output type O.
Implement this to add custom strategies; the built-in ones are exposed
through Output.
Required Methods§
Sourcefn response_format(&self) -> Option<ResponseFormat>
fn response_format(&self) -> Option<ResponseFormat>
The response format sent to the model.
Sourcefn parse_complete(&self, text: &str, ctx: &OutputContext) -> Result<O, Error>
fn parse_complete(&self, text: &str, ctx: &OutputContext) -> Result<O, Error>
Parses the complete text of the final step.
§Errors
Returns Error::NoObjectGenerated when the text does not satisfy the
strategy.
Sourcefn parse_partial(&self, text: &str) -> Option<JsonValue>
fn parse_partial(&self, text: &str) -> Option<JsonValue>
Parses partial text during streaming; None when nothing usable is
available yet.
Provided Methods§
Sourcefn wants_output(&self) -> bool
fn wants_output(&self) -> bool
Whether the call must produce an output (false only for NoOutput).
Sourcefn typed_partial(&self, _value: &JsonValue) -> Option<O>
fn typed_partial(&self, _value: &JsonValue) -> Option<O>
Converts a partial JSON value into the typed output when it already satisfies the schema.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".