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: 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 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: DecisionThe routing decision behind this call; selected_model_id() identifies the model to use.
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, Decision)
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.