pub struct NativeTools { /* private fields */ }Expand description
A ToolRuntime whose tools are Rust closures.
use graphrt_core::tool::{ToolOutput, ToolSpec};
use graphrt_core::tool_node::NativeTools;
let tools = NativeTools::new().with(
ToolSpec {
name: "echo".into(),
description: "Echo the `text` argument".into(),
parameters: serde_json::json!({
"type": "object",
"properties": { "text": { "type": "string" } },
"required": ["text"]
}),
},
|args| async move { Ok(ToolOutput::text(args["text"].as_str().unwrap_or_default())) },
);Implementations§
Source§impl NativeTools
impl NativeTools
Trait Implementations§
Source§impl Clone for NativeTools
impl Clone for NativeTools
Source§impl Debug for NativeTools
impl Debug for NativeTools
Source§impl Default for NativeTools
impl Default for NativeTools
Source§impl ToolRuntime for NativeTools
impl ToolRuntime for NativeTools
Source§fn call<'a>(
&'a self,
name: &'a str,
arguments: Value,
_context: &'a ToolCallContext,
) -> BoxFuture<'a, Result<ToolOutput, ToolError>>
fn call<'a>( &'a self, name: &'a str, arguments: Value, _context: &'a ToolCallContext, ) -> BoxFuture<'a, Result<ToolOutput, ToolError>>
Native handlers take only arguments; the context is not forwarded
(accepts_secrets stays false).
Source§fn accepts_secrets(&self) -> bool
fn accepts_secrets(&self) -> bool
Whether this runtime may receive plaintext secrets in a
ToolCallContext. Read moreAuto Trait Implementations§
impl !RefUnwindSafe for NativeTools
impl !UnwindSafe for NativeTools
impl Forget for NativeTools
impl Freeze for NativeTools
impl Move for NativeTools
impl Send for NativeTools
impl Sync for NativeTools
impl Unpin for NativeTools
impl UnsafeUnpin for NativeTools
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