pub trait ExtractExt: ChatProvider {
// Provided methods
fn extract<'a, T>(
&'a self,
request: &'a ChatRequest,
) -> impl Future<Output = Result<Extracted<T>>> + Send + 'a
where Self: Sync,
T: JsonSchema + DeserializeOwned + Send + 'a { ... }
fn extract_stream<'a, T>(
&'a self,
request: &'a ChatRequest,
) -> impl Future<Output = Result<ExtractionStream<Self::Stream, T>>> + Send + 'a
where Self: Sync,
T: JsonSchema + Send + 'a { ... }
}extract only.Expand description
Structured extraction for every chat provider.
Provided Methods§
Sourcefn extract<'a, T>(
&'a self,
request: &'a ChatRequest,
) -> impl Future<Output = Result<Extracted<T>>> + Send + 'a
fn extract<'a, T>( &'a self, request: &'a ChatRequest, ) -> impl Future<Output = Result<Extracted<T>>> + Send + 'a
Extract a T from the response to request, in one provider call.
The extraction mode is read from the request options (see
ExtractionMode) and removed from the derived request. For repair
or retries, use an Extractor.
§Errors
Returns provider errors as-is, with the extraction’s record attached
(ExtractionMetadata::from_error), and extraction failures as
Error::Extract, whose ExtractFailure carries the response
that could not be used.
Sourcefn extract_stream<'a, T>(
&'a self,
request: &'a ChatRequest,
) -> impl Future<Output = Result<ExtractionStream<Self::Stream, T>>> + Send + 'a
fn extract_stream<'a, T>( &'a self, request: &'a ChatRequest, ) -> impl Future<Output = Result<ExtractionStream<Self::Stream, T>>> + Send + 'a
Stream the extraction request for request.
The returned stream yields the provider’s events unchanged and keeps
the raw structured output seen so far
(ExtractionStream::partial_output); call
ExtractionStream::finish after it ends to parse the value. Makes
one provider call.
§Errors
Fails like extract before the stream opens.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".