Struct ToolSet
pub struct ToolSet { /* private fields */ }Expand description
An ordered group of tools, built once and handed to an agent.
Order is registration order and is what the model is shown. A set does
not judge names: two tools with the same name are both kept, and
LlmAgentBuilder::try_build is what
rejects them.
use adam_llm_agent::{ToolCtx, ToolError, ToolOutput, ToolSet, Tool, tools};
use adam_model::ToolSpec;
use async_trait::async_trait;
use serde_json::{Value, json};
struct Clock;
#[async_trait]
impl Tool for Clock {
fn spec(&self) -> ToolSpec {
ToolSpec {
name: "clock".into(),
description: "What time is it?".into(),
parameters: json!({"type": "object", "properties": {}}),
}
}
async fn call(&self, _ctx: &ToolCtx, _args: Value) -> Result<ToolOutput, ToolError> {
Ok(ToolOutput::text("12:00"))
}
}
let set: ToolSet = tools![Clock];
assert_eq!(set.names(), ["clock"]);Implementations§
§impl ToolSet
impl ToolSet
pub fn wrap(self, f: impl FnMut(Arc<dyn Tool>) -> Arc<dyn Tool>) -> ToolSet
pub fn wrap(self, f: impl FnMut(Arc<dyn Tool>) -> Arc<dyn Tool>) -> ToolSet
Replace every tool with what f makes of it: the place for middleware
such as redaction or logging that wraps a tool in another tool.
use adam_llm_agent::{DynTool, ToolSet};
let set = ToolSet::new().wrap(|tool: DynTool| tool);
assert!(set.is_empty());Trait Implementations§
§impl FromIterator<Arc<dyn Tool>> for ToolSet
impl FromIterator<Arc<dyn Tool>> for ToolSet
§impl IntoIterator for ToolSet
impl IntoIterator for ToolSet
§impl<'a> IntoIterator for &'a ToolSet
impl<'a> IntoIterator for &'a ToolSet
Auto Trait Implementations§
impl !RefUnwindSafe for ToolSet
impl !UnwindSafe for ToolSet
impl Freeze for ToolSet
impl Send for ToolSet
impl Sync for ToolSet
impl Unpin for ToolSet
impl UnsafeUnpin for ToolSet
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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§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§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
Wrap the input message
T in a tonic::Request§impl<L> LayerExt<L> for L
impl<L> LayerExt<L> for L
§fn named_layer<S>(&self, service: S) -> Layered<<L as Layer<S>>::Service, S>where
L: Layer<S>,
fn named_layer<S>(&self, service: S) -> Layered<<L as Layer<S>>::Service, S>where
L: Layer<S>,
Applies the layer to a service and wraps it in [
Layered].§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
§impl<T> ServiceExt for T
impl<T> ServiceExt for T
§fn map_response_body<F>(self, f: F) -> MapResponseBody<Self, F>where
Self: Sized,
fn map_response_body<F>(self, f: F) -> MapResponseBody<Self, F>where
Self: Sized,
Apply a transformation to the response body. Read more
§fn trace_for_http(self) -> Trace<Self, SharedClassifier<ServerErrorsAsFailures>>where
Self: Sized,
fn trace_for_http(self) -> Trace<Self, SharedClassifier<ServerErrorsAsFailures>>where
Self: Sized,
High level tracing that classifies responses using HTTP status codes. Read more
§fn trace_for_grpc(self) -> Trace<Self, SharedClassifier<GrpcErrorsAsFailures>>where
Self: Sized,
fn trace_for_grpc(self) -> Trace<Self, SharedClassifier<GrpcErrorsAsFailures>>where
Self: Sized,
High level tracing that classifies responses using gRPC headers. Read more