motleycrew.tools.code

Modules

aider_tool

postgresql_linter

python_linter

python_repl

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

Bases: MotleyTool

Python code verification tool

__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.

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

Bases: MotleyTool

PostgreSQL code verification tool.

__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.

class motleycrew.tools.code.AiderTool(model: str = None, return_direct: bool = False, exceptions_to_reflect: List[Exception] | None = None, **kwargs)

Bases: MotleyTool

Tool for code generation using Aider.

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

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.

class motleycrew.tools.code.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.

run(command: str) str
validate_input(command: str)