motleycrew.common

Common utilities, types, enums, exceptions, loggers etc.

Modules

aux_prompts

defaults

enums

Various enums used in the project.

exceptions

Exceptions for motleycrew

llms

Helper functions to initialize Language Models (LLMs) from different frameworks.

logging

Project logger configuration module

types

Various types and type protocols used in motleycrew.

utils

Various helpers and utility functions used throughout the project.

class motleycrew.common.AuxPrompts

Bases: object

Singleton containing miscellaneous auxiliary prompts. In rare cases where you need to customize these, you can modify them before instantiating your agents.

DIRECT_OUTPUT_ERROR_WITH_SINGLE_OUTPUT_HANDLER = 'You must call the `{output_handler}` tool to return the final output.'
DIRECT_OUTPUT_ERROR_WITH_MULTIPLE_OUTPUT_HANDLERS = 'You must call one of the following tools to return the final output: {output_handlers}'
AMBIGUOUS_OUTPUT_HANDLER_CALL_ERROR = 'You attempted to return output by calling `{current_output_handler}` tool, but included other tool calls in your response. You must only call one of the following tools to return: {output_handlers}.'
static get_direct_output_error_message(output_handlers: List[MotleyTool]) str
static get_ambiguous_output_handler_call_error_message(current_output_handler: MotleyTool, output_handlers: List[MotleyTool]) str
class motleycrew.common.Defaults

Bases: object

Default values for various settings.

DEFAULT_REACT_AGENT_MAX_ITERATIONS = 15
DEFAULT_LLM_PROVIDER = 'openai'
DEFAULT_LLM_NAME = 'gpt-4o'
DEFAULT_LLM_TEMPERATURE = 0.0
DEFAULT_GRAPH_STORE_TYPE = 'kuzu'
MODULE_INSTALL_COMMANDS = {'aider': 'pip install aider-chat', 'autogen': 'pip install pyautogen', 'crewai': 'pip install crewai', 'crewai_tools': "pip install 'crewai[tools]'", 'llama_index': 'pip install llama-index', 'lunary': 'pip install lunary', 'pglast': 'pip install pglast', 'replicate': 'pip install replicate'}
DEFAULT_NUM_THREADS = 4
DEFAULT_EVENT_LOOP_SLEEP = 1
DEFAULT_OUTPUT_HANDLER_MAX_ITERATIONS = 5
class motleycrew.common.MotleyAgentFactory(*args, **kwargs)

Bases: Protocol[AgentType]

Type protocol for an agent factory.

It is a function that accepts tools as an argument and returns an agent instance of an appropriate class.

Agent factory is typically needed because the agent may need the list of available tools or other context at the time of its creation (e.g. to compose the prompt), and it may not be available at the time of the agent wrapper initialization.

__init__(*args, **kwargs)
motleycrew.common.configure_logging(verbose: bool = False, debug: bool = False)

Logging configuration

Parameters:
  • verbose (bool, optional) – if true logging level = INFO

  • debug (bool, optional) – if true logging level = DEBUG else WARNING

Returns:

class motleycrew.common.AsyncBackend

Bases: object

Backends for parallel crew execution.

ASYNCIO

Asynchronous execution using asyncio.

THREADING

Parallel execution using threads.

NONE

Synchronous execution.

ASYNCIO = 'asyncio'
THREADING = 'threading'
NONE = 'none'
ALL = {'asyncio', 'none', 'threading'}
class motleycrew.common.GraphStoreType

Bases: object

KUZU = 'kuzu'
ALL = {'kuzu'}
class motleycrew.common.LLMProvider

Bases: object

OPENAI = 'openai'
ANTHROPIC = 'anthropic'
REPLICATE = 'replicate'
TOGETHER = 'together'
GROQ = 'groq'
OLLAMA = 'ollama'
ALL = {'anthropic', 'groq', 'ollama', 'openai', 'replicate', 'together'}
class motleycrew.common.LLMFramework

Bases: object

LANGCHAIN = 'langchain'
LLAMA_INDEX = 'llama_index'
ALL = {'langchain', 'llama_index'}
class motleycrew.common.LunaryEventName

Bases: object

START = 'start'
END = 'end'
UPDATE = 'update'
ERROR = 'error'
ALL = {'end', 'error', 'start', 'update'}
class motleycrew.common.LunaryRunType

Bases: object

LLM = 'llm'
AGENT = 'agent'
TOOL = 'tool'
CHAIN = 'chain'
EMBED = 'embed'
ALL = {'agent', 'chain', 'embed', 'llm', 'tool'}
class motleycrew.common.TaskUnitStatus

Bases: object

PENDING = 'pending'
RUNNING = 'running'
DONE = 'done'
ALL = {'done', 'pending', 'running'}