pub struct ToolNode { /* private fields */ }Expand description
A graph node that runs a directly runnable tool.
Implementations§
Source§impl ToolNode
impl ToolNode
Sourcepub fn new(
tool: Arc<dyn Tool>,
cfg: NodeConfig,
) -> Result<Arc<ToolNode>, WorkflowError>
pub fn new( tool: Arc<dyn Tool>, cfg: NodeConfig, ) -> Result<Arc<ToolNode>, WorkflowError>
A node running tool, with input and output schemas inferred as any (the empty schema
{}).
Sourcepub fn named(
name: &str,
tool: Arc<dyn Tool>,
cfg: NodeConfig,
) -> Result<Arc<ToolNode>, WorkflowError>
pub fn named( name: &str, tool: Arc<dyn Tool>, cfg: NodeConfig, ) -> Result<Arc<ToolNode>, WorkflowError>
As ToolNode::new with an explicit node name.
Sourcepub fn with_schemas(
tool: Arc<dyn Tool>,
input: Option<Value>,
output: Option<Value>,
cfg: NodeConfig,
) -> Result<Arc<ToolNode>, WorkflowError>
pub fn with_schemas( tool: Arc<dyn Tool>, input: Option<Value>, output: Option<Value>, cfg: NodeConfig, ) -> Result<Arc<ToolNode>, WorkflowError>
A node with the given schemas: a None schema is inferred as any ({}).
Trait Implementations§
Source§impl Node for ToolNode
impl Node for ToolNode
Source§fn run(&self, ctx: Context, input: Value) -> EventStream
fn run(&self, ctx: Context, input: Value) -> EventStream
Runs the tool under a tool context with its own call id and actions, and emits one event carrying the tool’s actions (minus any compaction) and its output; a string output is also the event’s content.
Source§fn description(&self) -> &str
fn description(&self) -> &str
The node’s human-readable description.
Source§fn config(&self) -> &NodeConfig
fn config(&self) -> &NodeConfig
The node’s configuration.
Source§fn input_schema(&self) -> Option<&Value>
fn input_schema(&self) -> Option<&Value>
None = no schema, no input validation.Source§fn output_schema(&self) -> Option<&Value>
fn output_schema(&self) -> Option<&Value>
None = no schema, no output validation.Source§fn validate_input(&self, v: Value) -> Result<Value, WorkflowError>
fn validate_input(&self, v: Value) -> Result<Value, WorkflowError>
Called by the scheduler before
run on every activation.Source§fn validate_output(&self, v: Value) -> Result<Value, WorkflowError>
fn validate_output(&self, v: Value) -> Result<Value, WorkflowError>
Called by the scheduler on every yielded event with an output.
Source§fn state_field_names(&self) -> Option<&[String]>
fn state_field_names(&self) -> Option<&[String]>
The names of the state fields the node binds as parameters;
None = node does not bind
state params.Auto Trait Implementations§
impl !RefUnwindSafe for ToolNode
impl !UnwindSafe for ToolNode
impl Forget for ToolNode
impl Freeze for ToolNode
impl Move for ToolNode
impl Send for ToolNode
impl Sync for ToolNode
impl Unpin for ToolNode
impl UnsafeUnpin for ToolNodewhere
*const ArcInner<ToolInner> is !null: UnsafeUnpin,
PhantomData<ArcInner<ToolInner>>: 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