pub struct CallModel {
pub algorithm: String,
pub request: Request,
pub models: Vec<ModelId>,
pub is_answer_call: bool,
/* 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.
Driver::call_model stamps the first candidate model onto the request before publishing
the call. A consumer that falls through to a later candidate must re-stamp it.
Fields§
§algorithm: StringThe 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: RequestThe request to serve; its model is stamped with the first candidate.
models: Vec<ModelId>Candidate models, tried in order until one answers. Never empty.
is_answer_call: boolTrue for an answer-generating call, false for classifier and judge calls.
Implementations§
Source§impl CallModel
impl CallModel
Sourcepub fn respond(self, result: Result<Response>) -> Result<()>
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.
Sourcepub fn into_parts(self) -> (Request, Vec<ModelId>)
pub fn into_parts(self) -> (Request, Vec<ModelId>)
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 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.