pub struct GatewayBroker { /* private fields */ }Expand description
A model broker that sends the Harness’s model rounds to the PromptForge Gateway and lists the Gateway’s models.
A Host passes this broker to the Harness as its [InferenceBroker].
The broker performs each Chat effect from the Engine as one model
round on a GatewayChat. It lists the Gateway’s models through
fetch_model_catalog. Both kinds of request go to the same API root
and authenticate with the same bearer key.
Every round uses the Engine’s default run limits from
[RunLimits::new]: the wait limit for each part of the response and
the cap on response size in bytes.
The broker’s futures, models included, need
a tokio runtime with its reactor and timer. A Host that uses this broker
must therefore await Harness::run inside such a runtime. The Harness’s
own futures run on any executor.
Implementations§
Source§impl GatewayBroker
impl GatewayBroker
Sourcepub fn new(endpoint: GatewayEndpoint, key: SecretString) -> GatewayBroker
pub fn new(endpoint: GatewayEndpoint, key: SecretString) -> GatewayBroker
Creates a broker that reaches the Gateway at endpoint with the
bearer key key.
endpoint is the Gateway’s OpenAI-compatible API root, the /v1
path. Model rounds and model-list requests both go to it.
Sourcepub fn chat_streaming(
&self,
_binding: ModelBinding,
messages: Vec<Message>,
tools: Vec<ToolSchema>,
options: CompletionOptions,
on_piece: Arc<dyn Fn(StreamDelta) + Send + Sync>,
) -> BoxFuture<Result<Box<Completion>, CompletionError>>
pub fn chat_streaming( &self, _binding: ModelBinding, messages: Vec<Message>, tools: Vec<ToolSchema>, options: CompletionOptions, on_piece: Arc<dyn Fn(StreamDelta) + Send + Sync>, ) -> BoxFuture<Result<Box<Completion>, CompletionError>>
Runs one model round and passes each piece of the reply to
on_piece as it arrives.
The round is the same one InferenceBroker::chat runs. on_piece
receives the pieces in the order the stream delivers them. The
returned completion holds the whole reply.
on_piece is called inline as each piece is read, so it must not
block.
Trait Implementations§
Source§impl Clone for GatewayBroker
impl Clone for GatewayBroker
Source§fn clone(&self) -> GatewayBroker
fn clone(&self) -> GatewayBroker
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for GatewayBroker
impl Debug for GatewayBroker
Source§impl InferenceBroker for GatewayBroker
impl InferenceBroker for GatewayBroker
Source§fn models(&self) -> BoxFuture<Result<ModelCatalog, CompletionError>>
fn models(&self) -> BoxFuture<Result<ModelCatalog, CompletionError>>
Auto Trait Implementations§
impl !RefUnwindSafe for GatewayBroker
impl !UnwindSafe for GatewayBroker
impl Freeze for GatewayBroker
impl Send for GatewayBroker
impl Sync for GatewayBroker
impl Unpin for GatewayBroker
impl UnsafeUnpin for GatewayBroker
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> ErasedDestructor for Twhere
T: 'static,
impl<A, B, T> HttpServerConnExec<A, B> for Twhere
B: Body,
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more