Skip to main content

CallModel

Struct CallModel 

Source
pub struct CallModel {
    pub algorithm: String,
    pub request: Request,
    pub decision: Decision,
    /* private fields */
}
Expand description

An offloaded model call, surfaced inside Step::CallModel.

The host reads the public fields, performs (or delegates) the model call, and fulfills it with respond — unblocking the algorithm’s Driver::call_model on the other side. switchyard-llm-client’s run is the ready-made consumer that does this for you. A host that only wants the routing outcome can take the contents with into_parts and never respond; dropping the stream ends the run.

The selected model and inbound route name live in separate, unambiguous places: the model identifier is decision.selected_model_id(), while request.llm_request.model is the inbound name the agent asked for (libsy never overwrites it). A client maps selected_model_id() to the provider model id it hits.

Fields§

§algorithm: String

The name of the algorithm that produced this call, so a host instrumenting the calls it serves can attribute its own spans to the algorithm behind them.

§request: Request

The request to serve; its model is the agent’s original name NOT the selected model. The caller making the request needs to change it to decision.selected_model_id() before sending.

§decision: Decision

The routing decision behind this call; selected_model_id() identifies the model to use.

Implementations§

Source§

impl CallModel

Source

pub fn respond(self, result: Result<Response>) -> Result<()>

Fulfill the promise with the caller’s model-call result. Pass Err(..) to propagate a failed model call back to the algorithm. Consumes the promise: it can only be fulfilled once.

Source

pub fn into_parts(self) -> (Request, Decision)

Take the call’s contents without answering it, dropping the promise — the routing outcome plus the request as the algorithm would have sent it, after any rewriting.

Should only be called if decision.is_answer_call is true as that is the final call. The algorithm’s Driver::call_model will fail with DriverError::Abandoned and the run ends there. Taking a call the algorithm does not depend on (a judge or classifier call) may instead let it fail open and complete with degraded routing.

An abandoned run is not recorded as a failed one. Dropping a CallModel without calling this still yields DriverError::ResponseDropped, which is.

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.

§

impl<T> FutureExt for T

§

fn with_context(self, otel_cx: Context) -> WithContext<Self>

Attaches the provided Context to this type, returning a WithContext wrapper. Read more
§

fn with_current_context(self) -> WithContext<Self>

Attaches the current Context to this type, returning a WithContext wrapper. Read more
§

impl<T> Instrument for T

§

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

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

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, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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

impl<T> WithSubscriber for T

§

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
§

fn with_current_subscriber(self) -> WithDispatch<Self>

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

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

§

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

§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,