Skip to main content

TranslatingLlmClient

Struct TranslatingLlmClient 

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

A client that dispatches neutral-IR requests to named targets.

Each ModelConfig defines a target’s provider model and backends. Each call resolves the target and wire format, encodes the request, applies auth and forwarded headers, sends the HTTP request with a shared [reqwest::Client], and decodes the response back to the neutral IR (buffered or streamed).

Implementations§

Source§

impl TranslatingLlmClient

Source

pub fn new(model_configs: &[ModelConfig]) -> Result<Self>

Builds a client over the given ModelConfigs, with a fresh shared HTTP client and the built-in translation codecs.

Source

pub fn without_rate_limit_cooldown(self) -> Self

Disable HTTP 429 cooldown so subsequent calls can receive the upstream error.

Source

pub fn backend_for( &self, target_name: &ModelId, format: WireFormat, ) -> Option<&Backend>

The target’s backend for format, or None if no matching backend exists.

Source

pub fn provider_model<'a>(&'a self, target_name: &'a ModelId) -> &'a ModelId

The target’s provider model ID, falling back to its name when none is configured.

Source

pub fn supports_auxiliary( &self, target_name: &ModelId, operation: AuxiliaryOperation, ) -> bool

Whether the target has a backend for operation.

Source

pub async fn get_model_properties( &self, target_name: &ModelId, format: WireFormat, timeout: Duration, ) -> Result<Value>

Reads llama.cpp model properties through the backend’s configured auth and headers.

Redirects are disabled so credentials cannot move to another origin.

Source

pub async fn call_auxiliary( &self, target_name: &ModelId, request: Request, operation: AuxiliaryOperation, ) -> Result<Value>

Calls a model-bearing auxiliary provider operation.

Returns an error when the model has no compatible backend or the upstream request fails or returns invalid JSON.

Source

pub async fn call_rewrite_model( &self, request: Request, target_name: Option<&ModelId>, ) -> Result<Response>

Calls the selected target using its configured provider model and backend. target_name takes precedence over the request’s model field. Request metadata selects the wire format, falling back to the target’s default.

Trait Implementations§

Source§

impl RoutedLlmClient for TranslatingLlmClient

Source§

fn provider_model<'a>(&'a self, target: &'a ModelId) -> &'a ModelId

Resolves a routing key for telemetry. Direct model clients keep the key unchanged.
Source§

fn call<'life0, 'async_trait>( &'life0 self, request: Request, ) -> Pin<Box<dyn Future<Output = Result<Response>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Make a request

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
§

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,

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.

§

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

§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns [Action::Follow] only if self and other return Action::Follow. Read more
§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns [Action::Follow] if either self or other returns Action::Follow. Read more
§

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