motleycrew.tools.code.python_repl

Functions

create_repl_tool()

Classes

PythonREPLTool([return_direct, ...])

Python REPL tool.

REPLToolInput(*, command)

Input for the REPL tool.

class motleycrew.tools.code.python_repl.PythonREPLTool(return_direct: bool = False, exceptions_to_reflect: List[Exception] | None = None)

Bases: MotleyTool

Python REPL tool. Use this to execute python commands.

Note that the tool’s output is the content printed to stdout by the executed code. Because of this, any data you want to be in the output should be printed using print(…).

__init__(return_direct: bool = False, exceptions_to_reflect: List[Exception] | None = None)

Initialize the MotleyTool.

Parameters:
  • name – Name of the tool (required if tool is None).

  • description – Description of the tool (required if tool is None).

  • args_schema – Schema of the tool arguments (required if tool is None).

  • tool – Langchain BaseTool to wrap.

  • return_direct – If True, the tool’s output will be returned directly to the user.

  • exceptions_to_reflect – List of exceptions to reflect back to the agent.

  • retry_config – Configuration for retry behavior. If None, exceptions will not be retried.

  • is_async – Indicates whether the tool is asynchronous.

class motleycrew.tools.code.python_repl.REPLToolInput(*, command: str)

Bases: BaseModel

Input for the REPL tool.

command: str
model_computed_fields: ClassVar[Dict[str, ComputedFieldInfo]] = {}

A dictionary of computed field names and their corresponding ComputedFieldInfo objects.

model_config: ClassVar[ConfigDict] = {}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

model_fields: ClassVar[Dict[str, FieldInfo]] = {'command': FieldInfo(annotation=str, required=True, description='code to execute')}

Metadata about the fields defined on the model, mapping of field names to [FieldInfo][pydantic.fields.FieldInfo] objects.

This replaces Model.__fields__ from Pydantic V1.

motleycrew.tools.code.python_repl.create_repl_tool()