pub struct PythonREPLTool { /* private fields */ }Expand description
Python 代码执行工具
在本地 Python 环境中执行代码并返回结果。 适用于数学计算、数据处理等需要 Python 生态的场景。
§安全警告
此工具默认禁用。必须调用 PythonREPLTool::with_dangerously_allow
才能执行代码。在生产环境中使用时应确保在沙箱环境中运行。
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
使用自定义 Python 路径
Sourcepub fn with_dangerously_allow(self, allow: bool) -> Self
pub fn with_dangerously_allow(self, allow: bool) -> Self
显式启用代码执行(默认禁用)
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