Skip to main content

ExtractorBuilder

Struct ExtractorBuilder 

Source
pub struct ExtractorBuilder<T>{ /* private fields */ }
Expand description

Builder for the Extractor

Implementations§

Source§

impl<T> ExtractorBuilder<T>

Source

pub fn new(model: impl Into<DynModel<Completion>>) -> Self

An extractor of T over model.

Source

pub fn from_agent_builder(builder: AgentBuilder) -> Self

Configure an agent builder for extraction of T, replacing its preamble, output schema, tool choice, and output mode. The tool choice is always ToolChoice::Required, since an extraction is one turn that must call the submit tool.

Source

pub fn append_preamble(self, preamble: &str) -> Self

Append instructions to the extractor’s preamble. The extraction preamble itself is fixed (it tells the model to call the output tool); this adds to it, as AgentBuilder::append_preamble does, and never replaces it.

Source

pub fn context(self, doc: &str) -> Self

Add a context document to the extractor

Source

pub fn additional_params(self, params: Value) -> Self

Set provider-specific parameters for every extraction attempt.

Source

pub fn max_tokens(self, max_tokens: u64) -> Self

Set the maximum number of tokens for the completion

Source

pub fn add_hook<H>(self, hook: H) -> Self
where H: AgentHook + 'static,

Add a provider-independent lifecycle hook to every extraction attempt.

Completion-response hooks receive canonical Rig content, usage, prompt, and identity fields, just like hooks attached directly to an agent.

Source

pub fn dynamic_context<I, F>(self, samples: usize, index: I) -> Self
where I: VectorStoreIndex<Filter = F> + 'static, F: DynamicSearchFilter + WasmCompatSend + WasmCompatSync + 'static,

Retrieve samples documents from index for every extraction.

This delegates to AgentBuilder::dynamic_context and therefore uses the same completion-call hook lifecycle as an agent.

Source

pub fn retries(self, retries: usize) -> Self

Set the maximum number of retries for the extractor.

Source

pub fn build(self) -> Extractor<T>

Build the Extractor

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WasmCompatSend for T
where T: Send,

Source§

impl<T> WasmCompatSync for T
where T: Sync,

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more