pub struct PythonREPLTool { /* private fields */ }Expand description
Python code execution tool
Executes code in a local Python environment and returns the result. Suitable for scenarios needing the Python ecosystem, such as math and data processing.
§Security warning
This tool is disabled by default. Call PythonREPLTool::with_dangerously_allow
to enable code execution. In production, ensure it runs inside a sandboxed environment.
Implementations§
Source§impl PythonREPLTool
impl PythonREPLTool
Sourcepub fn with_python_path(path: impl Into<String>) -> Self
pub fn with_python_path(path: impl Into<String>) -> Self
Uses a custom Python path
Sourcepub fn with_dangerously_allow(self, allow: bool) -> Self
pub fn with_dangerously_allow(self, allow: bool) -> Self
Explicitly enables code execution (disabled by default)
Sourcepub fn with_skip_dangerous_imports_check(self, skip: bool) -> Self
pub fn with_skip_dangerous_imports_check(self, skip: bool) -> Self
Disable dangerous import checking (default: enabled).
Trait Implementations§
Source§impl BaseTool for PythonREPLTool
impl BaseTool for PythonREPLTool
Source§fn description(&self) -> &str
fn description(&self) -> &str
Returns the tool description. Read more
Source§fn run<'life0, 'async_trait>(
&'life0 self,
input: String,
) -> Pin<Box<dyn Future<Output = Result<String, ToolError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn run<'life0, 'async_trait>(
&'life0 self,
input: String,
) -> Pin<Box<dyn Future<Output = Result<String, ToolError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Execute the tool (string version). Read more
Source§fn return_direct(&self) -> bool
fn return_direct(&self) -> bool
Whether to return result directly to user. Read more
Source§impl Default for PythonREPLTool
impl Default for PythonREPLTool
Source§impl Tool for PythonREPLTool
impl Tool for PythonREPLTool
Source§type Input = PythonREPLInput
type Input = PythonREPLInput
Input type (must support deserialization and JSON Schema).
Source§type Output = PythonREPLOutput
type Output = PythonREPLOutput
Output type (must support serialization).
Source§fn invoke<'life0, 'async_trait>(
&'life0 self,
input: Self::Input,
) -> Pin<Box<dyn Future<Output = Result<Self::Output, ToolError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn invoke<'life0, 'async_trait>(
&'life0 self,
input: Self::Input,
) -> Pin<Box<dyn Future<Output = Result<Self::Output, ToolError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Execute the tool. Read more
Source§fn args_schema(&self) -> Option<Value>
fn args_schema(&self) -> Option<Value>
Returns the input JSON Schema.
Auto Trait Implementations§
impl Freeze for PythonREPLTool
impl RefUnwindSafe for PythonREPLTool
impl Send for PythonREPLTool
impl Sync for PythonREPLTool
impl Unpin for PythonREPLTool
impl UnsafeUnpin for PythonREPLTool
impl UnwindSafe for PythonREPLTool
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