pub struct HttpModel { /* private fields */ }Expand description
A model reached over HTTP through an injected Transport.
Unary and streamed calls share one encoder, one decoder per protocol
and one Fold, so both return the same response for the same reply.
Implementations§
Source§impl HttpModel
impl HttpModel
Sourcepub fn new(
id: impl Into<String>,
model: impl Into<String>,
endpoint: Endpoint,
key: Option<Secret>,
transport: Arc<dyn Transport>,
) -> Result<Self, ProviderError>
pub fn new( id: impl Into<String>, model: impl Into<String>, endpoint: Endpoint, key: Option<Secret>, transport: Arc<dyn Transport>, ) -> Result<Self, ProviderError>
Builds a model named id (usually vendor/model) that sends wire
model to endpoint with an optional key through transport.
Returns BadRequest when model fails valid_model_id.
Trait Implementations§
Source§impl Model for HttpModel
impl Model for HttpModel
fn id(&self) -> &str
fn complete<'life0, 'life1, 'async_trait>(
&'life0 self,
req: &'life1 CompletionRequest,
) -> Pin<Box<dyn Future<Output = Result<CompletionResponse, ProviderError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn stream<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
req: &'life1 CompletionRequest,
on_delta: &'life2 mut (dyn for<'d> FnMut(&'d Delta) + Send),
) -> Pin<Box<dyn Future<Output = Result<CompletionResponse, ProviderError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Source§fn complete_billed<'life0, 'life1, 'async_trait>(
&'life0 self,
req: &'life1 CompletionRequest,
) -> Pin<Box<dyn Future<Output = Result<CompletionResponse, FailedCall>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn complete_billed<'life0, 'life1, 'async_trait>(
&'life0 self,
req: &'life1 CompletionRequest,
) -> Pin<Box<dyn Future<Output = Result<CompletionResponse, FailedCall>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Runs
complete and, when the call fails, keeps the usage the
provider reported before it failed, so a caller can bill it.
Default: complete with zero usage. A model that sees usage
overrides it, and a wrapper forwards it to its inner model.Source§fn stream_billed<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
req: &'life1 CompletionRequest,
on_delta: &'life2 mut (dyn for<'d> FnMut(&'d Delta) + Send),
) -> Pin<Box<dyn Future<Output = Result<CompletionResponse, FailedCall>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn stream_billed<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
req: &'life1 CompletionRequest,
on_delta: &'life2 mut (dyn for<'d> FnMut(&'d Delta) + Send),
) -> Pin<Box<dyn Future<Output = Result<CompletionResponse, FailedCall>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Runs
stream and, when the call fails, keeps the usage the
provider reported before it failed, as complete_billed does.
Default: stream with zero usage.Source§fn prices_replies(&self) -> bool
fn prices_replies(&self) -> bool
Reports whether each reply’s
usage.cost_usd_micros is already the
cost of the model that served it, as a routed or metered model’s is.
A run then bills that cost instead of its own price, so a retry or
fallback that sums priced tries is billed that sum. Default false.Source§fn meter_price(&self) -> Option<Price>
fn meter_price(&self) -> Option<Price>
Returns the price that meters each try when every reply is priced
at one price, as a metered model and a retry over one are.
A caller trusts the reply cost only when it equals its own declared
price. Default
None.Source§fn extra_calls(&self, req: &CompletionRequest) -> u32
fn extra_calls(&self, req: &CompletionRequest) -> u32
Returns how many more provider calls one call with
req can make
after the first, each resending req with the previous reply and
at most RESEND_NOTE_BYTES of note. A run budgets them before the
call. Default 0.Auto Trait Implementations§
impl !RefUnwindSafe for HttpModel
impl !UnwindSafe for HttpModel
impl Forget for HttpModel
impl Freeze for HttpModel
impl Move for HttpModel
impl Send for HttpModel
impl Sync for HttpModel
impl Unpin for HttpModel
impl UnsafeUnpin for HttpModelwhere
*const u8 is !null: UnsafeUnpin,
PhantomData<u8>: UnsafeUnpin,
*const ArcInner<dyn Transport> is !null: UnsafeUnpin,
PhantomData<ArcInner<dyn Transport>>: UnsafeUnpin,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more