motleycrew.crew
MotleyCrew class, orchestration and related functionality.
Modules
Thread pool module for running agents. |
- class motleycrew.crew.MotleyCrew(graph_store: MotleyGraphStore | None = None, async_backend: AsyncBackend = 'none', num_threads: int = 4)
Bases:
object
The main class for executing tasks and orchestrating agents.
- __init__(graph_store: MotleyGraphStore | None = None, async_backend: AsyncBackend = 'none', num_threads: int = 4)
Initialize the crew.
- Parameters:
graph_store – The graph store to use. If not provided, a new one will be created with default settings.
async_backend – The type of async backend to use. Defaults to
AsyncBackend.NONE
, which means the crew will run synchronously. The other options areAsyncBackend.ASYNCIO
andAsyncBackend.THREADING
.num_threads – The number of threads to use when running in threaded mode.
- add_dependency(upstream: Task, downstream: Task)
Add a dependency between two tasks in the graph store.
- Parameters:
upstream – The upstream task.
downstream – The downstream task.
- register_tasks(tasks: Collection[Task])
Insert tasks into the crew’s graph store.
- Parameters:
tasks – The tasks to register.
- get_available_tasks() list[Task]
Get tasks that are able to dispatch units at the moment. These are tasks that have no upstream dependencies that are not done.
- Returns:
List of tasks that are available.
- add_task_unit_to_graph(task: Task, unit: TaskUnitType)
Add a task unit to the graph and connect it to its task.
- Parameters:
task – The task to which the unit belongs.
unit – The unit to add.
- get_extra_tools(task: Task) list[MotleyTool]
Get tools that should be added to the agent for a given task.
- Parameters:
task – The task for which to get extra tools.
- check_cyclical_dependencies()