Skip to main content

ScriptedTasks

Struct ScriptedTasks 

Source
pub struct ScriptedTasks { /* private fields */ }
Expand description

Answers each task from its own queue of JSON documents.

Implementations§

Source§

impl ScriptedTasks

Source

pub fn new(provider: impl Into<ProviderKey>, model: impl Into<ModelKey>) -> Self

A provider with native schema support and no answers yet.

Source

pub fn answer(self, task: &str, answer: Value) -> Self

Queues answer for the task or call task.

Source

pub fn failing(self, task: &str, error: ProviderError) -> Self

Queues a provider failure for the task or call task.

Source

pub fn tagged(self, tag: impl Into<String>) -> Self

Adds a tag to the profile, for routing by tag.

Source

pub fn calls(&self) -> Vec<ModelRequest>

Every request received, in order.

Source

pub fn called(&self) -> Vec<String>

The task ids called, in order.

Source

pub fn unanswered(&self) -> Vec<String>

Tasks with answers never asked for.

Source

pub fn router(self: &Arc<Self>) -> Arc<PolicyRouter> ⓘ

A router over this provider alone.

Trait Implementations§

Source§

impl Debug for ScriptedTasks

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl ModelProvider for ScriptedTasks

Source§

fn provider_key(&self) -> ProviderKey

The configured provider key, e.g. "openai". Labels every metric, attempt record and replay entry this provider produces.
Source§

fn model_key(&self) -> ModelKey

The configured model key, e.g. "gpt-4o-2024-08-06".
Source§

fn capabilities(&self) -> ProviderCapabilities

What this provider-model pair can actually do (spec §20.3). Read more
Source§

fn profile(&self) -> ModelProfile

The full routing profile: keys, capabilities, and the cost, region and tags routing filters on. Read more
Source§

fn generate<'life0, 'async_trait>( &'life0 self, request: ModelRequest, ) -> Pin<Box<dyn Future<Output = Result<ModelResponse, ProviderError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Runs one model call and returns the whole answer. Read more
Source§

fn reference(&self) -> ModelRef

The provider-model pair, as routing and health tracking key it.
Source§

fn supports( &self, requirements: &CapabilityRequirements, ) -> Result<(), CapabilityMismatch>

Checks the declared capabilities against requirements. Read more
Source§

fn stream<'life0, 'async_trait>( &'life0 self, request: ModelRequest, ) -> Pin<Box<dyn Future<Output = Result<ModelStream, ProviderError>> + Send + 'async_trait>>
where 'life0: 'async_trait, Self: 'async_trait,

Runs one model call and returns its answer incrementally. Read more

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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

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, 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> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

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> 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