diff --git a/motleycrew/agents/crewai/agent_with_config.py b/motleycrew/agents/crewai/agent_with_config.py index 4067f91f..2affa2db 100644 --- a/motleycrew/agents/crewai/agent_with_config.py +++ b/motleycrew/agents/crewai/agent_with_config.py @@ -1,3 +1,4 @@ +""" Module description """ from typing import Any, Optional, List from langchain_core.runnables import RunnableConfig @@ -12,12 +13,17 @@ class CrewAIAgentWithConfig(Agent): - """ - Subclass for CrewAI Agent that overrides the execute_task method to include a config parameter. - TODO: get rid of this when https://github.com/joaomdmoura/crewAI/pull/483 is merged. - """ - + def __init__(self, *args, **kwargs): + """Subclass for CrewAI Agent that overrides the execute_task method to include a config parameter. + + Args: + *args: + **kwargs: + + Todo: + * get rid of this when https://github.com/joaomdmoura/crewAI/pull/483 is merged. + """ ensure_module_is_installed("crewai") super(CrewAIAgentWithConfig, self).__init__(*args, **kwargs) @@ -31,12 +37,13 @@ def execute_task( """Execute a task with the agent. Args: - task: Task to execute. - context: Context to execute the task in. - tools: Tools to use for the task. - config: Runnable config + task (Any): Task to execute. + context (:obj:'str', optional): Context to execute the task in. + tools: (:obj:'List[Any]', optional): Tools to use for the task. + config (:obj:'RunnableConfig', optional): Runnable config. + Returns: - Output of the agent + Any: Output of the agent """ task_prompt = task.prompt() diff --git a/motleycrew/agents/crewai/crewai.py b/motleycrew/agents/crewai/crewai.py index 14a54b30..d19df5b0 100644 --- a/motleycrew/agents/crewai/crewai.py +++ b/motleycrew/agents/crewai/crewai.py @@ -1,3 +1,4 @@ +""" Module description """ from typing import Any, Optional, Sequence from langchain_core.runnables import RunnableConfig @@ -26,6 +27,15 @@ def __init__( tools: Sequence[MotleySupportedTool] | None = None, verbose: bool = False, ): + """ Description + + Args: + goal (str): + name (:obj:'str', optional): + agent_factory (:obj:'MotleyAgentFactory', optional): + tools (:obj:'Sequence[MotleySupportedTool]', optional: + verbose (bool): + """ ensure_module_is_installed("crewai") super().__init__( description=goal, @@ -41,6 +51,16 @@ def invoke( config: Optional[RunnableConfig] = None, **kwargs: Any, ) -> Any: + """ Description + + Args: + task_dict (dict): + config (:obj:'RunnableConfig', optional): + **kwargs: + + Returns: + Any: + """ self.materialize() prompt = task_dict.get("prompt") @@ -59,9 +79,25 @@ def invoke( # TODO: what do these do? def set_cache_handler(self, cache_handler: Any) -> None: + """ Description + + Args: + cache_handler (Any): + + Returns: + None: + """ return self.agent.set_cache_handler(cache_handler) def set_rpm_controller(self, rpm_controller: Any) -> None: + """ Description + + Args: + rpm_controller (Any): + + Returns: + None: + """ return self.agent.set_rpm_controller(rpm_controller) @staticmethod @@ -70,6 +106,16 @@ def from_agent( tools: Sequence[MotleySupportedTool] | None = None, verbose: bool = False, ) -> "CrewAIMotleyAgentParent": + """ Description + + Args: + agent (CrewAIAgentWithConfig): + tools (:obj:'Sequence[MotleySupportedTool]', optional): + verbose (bool): + + Returns: + CrewAIMotleyAgentParent: + """ if tools or agent.tools: tools = list(tools or []) + list(agent.tools or []) diff --git a/motleycrew/agents/crewai/crewai_agent.py b/motleycrew/agents/crewai/crewai_agent.py index f2f40c18..5824618e 100644 --- a/motleycrew/agents/crewai/crewai_agent.py +++ b/motleycrew/agents/crewai/crewai_agent.py @@ -1,3 +1,4 @@ +""" Module description """ from typing import Optional, Any, Sequence from motleycrew.tools import MotleyTool @@ -20,6 +21,17 @@ def __init__( llm: Optional[Any] = None, verbose: bool = False, ): + """ Description + + Args: + role (str): + goal (str): + backstory (str): + delegation (bool): + tools (:obj:'Sequence[MotleySupportedTool]', optional): + llm (:obj:'Any', optional): + verbose (bool): + """ if tools is None: tools = []