pub struct Router { /* private fields */ }Expand description
A chain of providers behind the ChatProvider interface. Build one per run: its state is
the run’s record of which routes have already failed.
Implementations§
Trait Implementations§
Source§impl ChatProvider for Router
impl ChatProvider for Router
Source§fn can_see(&self) -> bool
fn can_see(&self) -> bool
What the route the next turn starts on declares (#361).
The default says false, which would refuse a picture on every chain — the router is the
provider a chained run holds, so this is the only place the answer can come from. The state
lock is taken and released before asking, because a provider’s can_see is its own.
Source§fn chat<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
messages: &'life1 [Message],
tools: &'life2 [ToolSpec],
) -> Pin<Box<dyn Future<Output = Result<Message>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn chat<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
messages: &'life1 [Message],
tools: &'life2 [ToolSpec],
) -> Pin<Box<dyn Future<Output = Result<Message>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Send the conversation and return the assistant’s reply (text and/or tool calls).
Source§fn chat_stream<'life0, 'life1, 'life2, 'life3, 'async_trait>(
&'life0 self,
messages: &'life1 [Message],
tools: &'life2 [ToolSpec],
on_delta: DeltaFn<'life3>,
) -> Pin<Box<dyn Future<Output = Result<Message>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
fn chat_stream<'life0, 'life1, 'life2, 'life3, 'async_trait>(
&'life0 self,
messages: &'life1 [Message],
tools: &'life2 [ToolSpec],
on_delta: DeltaFn<'life3>,
) -> Pin<Box<dyn Future<Output = Result<Message>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
Like
chat, but reports assistant text through on_delta as it is
generated. The returned message is always the complete reply. Providers that
cannot stream just answer normally and emit no deltas.Source§fn chat_stream_patched<'life0, 'life1, 'life2, 'life3, 'life4, 'async_trait>(
&'life0 self,
messages: &'life1 [Message],
tools: &'life2 [ToolSpec],
on_delta: DeltaFn<'life3>,
patch: &'life4 RequestPatch,
) -> Pin<Box<dyn Future<Output = Result<Message>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
'life4: 'async_trait,
fn chat_stream_patched<'life0, 'life1, 'life2, 'life3, 'life4, 'async_trait>(
&'life0 self,
messages: &'life1 [Message],
tools: &'life2 [ToolSpec],
on_delta: DeltaFn<'life3>,
patch: &'life4 RequestPatch,
) -> Pin<Box<dyn Future<Output = Result<Message>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
'life4: 'async_trait,
One streaming turn with a request patch applied. Read more
Source§fn take_usage(&self) -> Option<TurnUsage>
fn take_usage(&self) -> Option<TurnUsage>
What the most recent call cost, if the server said. Taken rather than borrowed so a
caller cannot show the same turn twice; providers that do not measure return
None.Auto Trait Implementations§
impl !Freeze for Router
impl !RefUnwindSafe for Router
impl !UnwindSafe for Router
impl Forget for Router
impl Move for Router
impl Send for Router
impl Sync for Router
impl Unpin for Router
impl UnsafeUnpin for Routerwhere
*const u8 is !null: UnsafeUnpin,
PhantomData<RouterEntry>: UnsafeUnpin,
Align4<u32>: UnsafeUnpin,
Align1<u8>: UnsafeUnpin,
PhantomData<Hop>: 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