pub struct ToolCallRouter { /* private fields */ }Expand description
Hybrid tool-call router backed by a local FunctionGemma model.
Created once at session start; shared via Arc across prompt calls.
Implementations§
Source§impl ToolCallRouter
impl ToolCallRouter
Sourcepub fn from_config(config: &ToolRouterConfig) -> Result<Option<Self>>
pub fn from_config(config: &ToolRouterConfig) -> Result<Option<Self>>
Construct from a ToolRouterConfig.
Returns None if the router is disabled or missing required paths.
Sourcepub async fn maybe_reformat(
&self,
response: CompletionResponse,
tools: &[ToolDefinition],
) -> CompletionResponse
pub async fn maybe_reformat( &self, response: CompletionResponse, tools: &[ToolDefinition], ) -> CompletionResponse
Conditionally reformat a CompletionResponse.
- If the response already contains
ContentPart::ToolCallentries, return it unchanged (zero overhead path). - If the response is text-only, run FunctionGemma to convert the text into structured tool calls.
- On any internal error, return the original response unchanged (safe degradation — the router never breaks existing functionality).
Trait Implementations§
Auto Trait Implementations§
impl Freeze for ToolCallRouter
impl RefUnwindSafe for ToolCallRouter
impl Send for ToolCallRouter
impl Sync for ToolCallRouter
impl Unpin for ToolCallRouter
impl UnwindSafe for ToolCallRouter
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
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> 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>
Converts
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>
Converts
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