🐫 CAMEL: The first and the best multi-agent framework. Finding the Scaling Law of Agents. https://www.camel-ai.org
Python agentai-societiesartificial-intelligencecommunicative-aicooperative-aideep-learninglarge-language-modelsmulti-agent-systemsnatural-language-processing
enhance: Workforce Docstring (#2506)
Hesam Sheikh91132b7cfd3e
diff --git a/camel/societies/workforce/workforce.py b/camel/societies/workforce/workforce.pyindex 373dd9cf1..3bcad9e67 100644--- a/camel/societies/workforce/workforce.py+++ b/camel/societies/workforce/workforce.py@@ -48,29 +48,58 @@ logger = get_logger(__name__)class Workforce(BaseNode):- r"""A system where multiple workder nodes (agents) cooperate together- to solve tasks. It can assign tasks to workder nodes and also take+ r"""A system where multiple worker nodes (agents) cooperate together+ to solve tasks. It can assign tasks to worker nodes and also takestrategies such as create new worker, decompose tasks, etc. to handlesituations when the task fails.+ The workforce uses three specialized ChatAgents internally:+ - Coordinator Agent: Assigns tasks to workers based on their+ capabilities+ - Task Planner Agent: Decomposes complex tasks and composes results+ - Dynamic Workers: Created at runtime when tasks fail repeatedly+Args:- description (str): Description of the node.+ description (str): Description of the workforce.children (Optional[List[BaseNode]], optional): List of child nodesunder this node. Each child node can be a worker node oranother workforce node. (default: :obj:`None`)coordinator_agent_kwargs (Optional[Dict], optional): Keyword- arguments for the coordinator agent, e.g. `model`, `api_key`,- `tools`, etc. If not provided, default model settings will be used.- (default: :obj:`None`)- task_agent_kwargs (Optional[Dict], optional): Keyword arguments for- the task agent, e.g. `model`, `api_key`, `tools`, etc.- If not provided, default model settings will be used.- (default: :obj:`None`)- new_worker_agent_kwargs (Optional[Dict]): Default keyword arguments- for the worker agent that will be created during runtime to- handle failed tasks, e.g. `model`, `api_key`, `tools`, etc.- If not provided, default model settings will be used.- (default: :obj:`None`)+ arguments passed directly to the coordinator :obj:`ChatAgent`+ constructor. The coordinator manages task assignment and failure+ handling strategies. See :obj:`ChatAgent` documentation+ for all available parameters.+ (default: :obj:`None` - uses ModelPlatformType.DEFAULT,+ ModelType.DEFAULT)+ task_agent_kwargs (Optional[Dict], optional): Keyword arguments+ passed directly to the task planning :obj:`ChatAgent` constructor.+ The task agent handles task decomposition into subtasks and result+ composition. See :obj:`ChatAgent` documentation for all+ available parameters.+ (default: :obj:`None` - uses ModelPlatformType.DEFAULT,+ ModelType.DEFAULT)+ new_worker_agent_kwargs (Optional[Dict], optional): Default keyword+ arguments passed to :obj:`ChatAgent` constructor for workers+ created dynamically at runtime when existing workers cannot handle+ failed tasks. See :obj:`ChatAgent` documentation for all+ available parameters.+ (default: :obj:`None` - creates workers with SearchToolkit,+ CodeExecutionToolkit, and ThinkingToolkit)++ Example:+ >>> # Configure with custom model+ >>> model = ModelFactory.create(+ ... ModelPlatformType.OPENAI, ModelType.GPT_4O+ ... )+ >>> workforce = Workforce(+ ... "Research Team",+ ... coordinator_agent_kwargs={"model": model, "token_limit": 4000},+ ... task_agent_kwargs={"model": model, "token_limit": 8000}+ ... )+ >>>+ >>> # Process a task+ >>> task = Task(content="Research AI trends", id="1")+ >>> result = workforce.process_task(task)"""def __init__(@@ -89,21 +118,33 @@ class Workforce(BaseNode):# Warning messages for default model usageif coordinator_agent_kwargs is None:logger.warning(- "No coordinator_agent_kwargs provided. "- "Using `ModelPlatformType.DEFAULT` and `ModelType.DEFAULT` "- "for coordinator agent."+ "No coordinator_agent_kwargs provided. Using default "+ "ChatAgent settings (ModelPlatformType.DEFAULT, "+ "ModelType.DEFAULT). To customize the coordinator agent "+ "that assigns tasks and handles failures, pass a dictionary "+ "with ChatAgent parameters, e.g.: {'model': your_model, "+ "'tools': your_tools, 'token_limit': 8000}. See ChatAgent "+ "documentation for all available options.")if task_agent_kwargs is None:logger.warning(- "No task_agent_kwargs provided. "- "Using `ModelPlatformType.DEFAULT` and `ModelType.DEFAULT` "- "for task agent."+ "No task_agent_kwargs provided. Using default ChatAgent "+ "settings (ModelPlatformType.DEFAULT, ModelType.DEFAULT). "+ "To customize the task planning agent that "+ "decomposes/composes tasks, pass a dictionary with "+ "ChatAgent parameters, e.g.: {'model': your_model, "+ "'token_limit': 16000}. See ChatAgent documentation for "+ "all available options.")if new_worker_agent_kwargs is None:logger.warning(- "No new_worker_agent_kwargs provided. "- "Using `ModelPlatformType.DEFAULT` and `ModelType.DEFAULT` "- "for worker agents created during runtime."+ "No new_worker_agent_kwargs provided. Workers created at "+ "runtime will use default ChatAgent settings with "+ "SearchToolkit, CodeExecutionToolkit, and ThinkingToolkit. "+ "To customize runtime worker creation, pass a dictionary "+ "with ChatAgent parameters, e.g.: {'model': your_model, "+ "'tools': your_tools}. See ChatAgent documentation for all "+ "available options.")coord_agent_sys_msg = BaseMessage.make_assistant_message(diff --git a/docs/mintlify/docs.json b/docs/mintlify/docs.jsonindex 9efdc8e93..c1686dca2 100644--- a/docs/mintlify/docs.json+++ b/docs/mintlify/docs.json@@ -619,6 +619,7 @@"reference/camel.loaders.jina_url_reader","reference/camel.loaders.markitdown","reference/camel.loaders.mineru_extractor",+ "reference/camel.loaders.mistral_reader","reference/camel.loaders.pandas_reader","reference/camel.loaders.scrapegraph_reader","reference/camel.loaders.unstructured_io"diff --git a/docs/mintlify/reference/camel.loaders.mistral_reader.mdx b/docs/mintlify/reference/camel.loaders.mistral_reader.mdxnew file mode 100644index 000000000..75ed46485--- /dev/null+++ b/docs/mintlify/reference/camel.loaders.mistral_reader.mdx@@ -0,0 +1,75 @@+<a id="camel.loaders.mistral_reader"></a>++<a id="camel.loaders.mistral_reader.MistralReader"></a>++## MistralReader++```python+class MistralReader:+```++Mistral Document Loader.++<a id="camel.loaders.mistral_reader.MistralReader.__init__"></a>++### __init__++```python+def __init__(+ self,+ api_key: Optional[str] = None,+ model: Optional[str] = 'mistral-ocr-latest'+):+```++Initialize the MistralReader.++**Parameters:**++- **api_key** (Optional[str]): The API key for the Mistral API. (default: :obj:`None`)+- **model** (Optional[str]): The model to use for OCR. (default: :obj:`"mistral-ocr-latest"`)++<a id="camel.loaders.mistral_reader.MistralReader._encode_file"></a>++### _encode_file++```python+def _encode_file(self, file_path: str):+```++Encode the pdf to base64.++**Parameters:**++- **file_path** (str): Path to the input file.++**Returns:**++ str: base64 version of the file.++<a id="camel.loaders.mistral_reader.MistralReader.extract_text"></a>++### extract_text++```python+def extract_text(+ self,+ file_path: str,+ is_image: bool = False,+ pages: Optional[List[int]] = None,+ include_image_base64: Optional[bool] = None+):+```++Converts the given file to Markdown format.++**Parameters:**++- **file_path** (str): Path to the input file or a remote URL.+- **is_image** (bool): Whether the file or URL is an image. If True, uses image_url type instead of document_url. (default: :obj:`False`)+- **pages** (Optional[List[int]]): Specific pages user wants to process in various formats: single number, range, or list of both. Starts from 0. (default: :obj:`None`)+- **include_image_base64** (Optional[bool]): Whether to include image URLs in response. (default: :obj:`None`)++**Returns:**++ OCRResponse: page wise extractions.diff --git a/docs/mintlify/reference/camel.societies.workforce.workforce.mdx b/docs/mintlify/reference/camel.societies.workforce.workforce.mdxindex ca75c2e52..189f4582d 100644--- a/docs/mintlify/reference/camel.societies.workforce.workforce.mdx+++ b/docs/mintlify/reference/camel.societies.workforce.workforce.mdx@@ -8,18 +8,24 @@class Workforce(BaseNode):```-A system where multiple workder nodes (agents) cooperate together-to solve tasks. It can assign tasks to workder nodes and also take+A system where multiple worker nodes (agents) cooperate together+to solve tasks. It can assign tasks to worker nodes and also takestrategies such as create new worker, decompose tasks, etc. to handlesituations when the task fails.+The workforce uses three specialized ChatAgents internally:+- Coordinator Agent: Assigns tasks to workers based on their+capabilities+- Task Planner Agent: Decomposes complex tasks and composes results+- Dynamic Workers: Created at runtime when tasks fail repeatedly+**Parameters:**-- **description** (str): Description of the node.+- **description** (str): Description of the workforce.- **children** (Optional[List[BaseNode]], optional): List of child nodes under this node. Each child node can be a worker node or another workforce node. (default: :obj:`None`)-- **coordinator_agent_kwargs** (Optional[Dict], optional): Keyword arguments for the coordinator agent, e.g. `model`, `api_key`, `tools`, etc. If not provided, default model settings will be used. (default: :obj:`None`)-- **task_agent_kwargs** (Optional[Dict], optional): Keyword arguments for the task agent, e.g. `model`, `api_key`, `tools`, etc. If not provided, default model settings will be used. (default: :obj:`None`)-- **new_worker_agent_kwargs** (Optional[Dict]): Default keyword arguments for the worker agent that will be created during runtime to handle failed tasks, e.g. `model`, `api_key`, `tools`, etc. If not provided, default model settings will be used. (default: :obj:`None`)+- **coordinator_agent_kwargs** (Optional[Dict], optional): Keyword arguments passed directly to the coordinator :obj:`ChatAgent` constructor. The coordinator manages task assignment and failure handling strategies. See :obj:`ChatAgent` documentation for all available parameters. (default: :obj:`None` - uses ModelPlatformType.DEFAULT, ModelType.DEFAULT)+- **task_agent_kwargs** (Optional[Dict], optional): Keyword arguments passed directly to the task planning :obj:`ChatAgent` constructor. The task agent handles task decomposition into subtasks and result composition. See :obj:`ChatAgent` documentation for all available parameters. (default: :obj:`None` - uses ModelPlatformType.DEFAULT, ModelType.DEFAULT)+- **new_worker_agent_kwargs** (Optional[Dict], optional): Default keyword arguments passed to :obj:`ChatAgent` constructor for workers created dynamically at runtime when existing workers cannot handle failed tasks. See :obj:`ChatAgent` documentation for all available parameters. (default: :obj:`None` - creates workers with SearchToolkit, CodeExecutionToolkit, and ThinkingToolkit)<a id="camel.societies.workforce.workforce.Workforce.__init__"></a>