🐫 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
Auto-update documentation after merge
camel-docs-bot621f9c716879
diff --git a/docs/reference/camel.societies.workforce.utils.md b/docs/reference/camel.societies.workforce.utils.mdindex d44c9ad17..7f531ef30 100644--- a/docs/reference/camel.societies.workforce.utils.md+++ b/docs/reference/camel.societies.workforce.utils.md@@ -58,6 +58,52 @@ class TaskAssignResult(BaseModel):The result of task assignment for both single and batch assignments.+<a id="camel.societies.workforce.utils.RecoveryStrategy"></a>++## RecoveryStrategy++```python+class RecoveryStrategy(str, Enum):+```++Strategies for handling failed tasks.++<a id="camel.societies.workforce.utils.RecoveryStrategy.__str__"></a>++### __str__++```python+def __str__(self):+```++<a id="camel.societies.workforce.utils.RecoveryStrategy.__repr__"></a>++### __repr__++```python+def __repr__(self):+```++<a id="camel.societies.workforce.utils.FailureContext"></a>++## FailureContext++```python+class FailureContext(BaseModel):+```++Context information about a task failure.++<a id="camel.societies.workforce.utils.RecoveryDecision"></a>++## RecoveryDecision++```python+class RecoveryDecision(BaseModel):+```++Decision on how to recover from a task failure.+<a id="camel.societies.workforce.utils.check_if_running"></a>## check_if_runningdiff --git a/docs/reference/camel.societies.workforce.workforce.md b/docs/reference/camel.societies.workforce.workforce.mdindex be56de108..e665d7410 100644--- a/docs/reference/camel.societies.workforce.workforce.md+++ b/docs/reference/camel.societies.workforce.workforce.md@@ -175,6 +175,26 @@ Update dependency tracking when a task is decomposed into subtasks.Tasks that depended on the original task should now depend on allsubtasks. The last subtask inherits the original task's dependencies.+<a id="camel.societies.workforce.workforce.Workforce._increment_in_flight_tasks"></a>++### _increment_in_flight_tasks++```python+def _increment_in_flight_tasks(self, task_id: str):+```++Safely increment the in-flight tasks counter with logging.++<a id="camel.societies.workforce.workforce.Workforce._decrement_in_flight_tasks"></a>++### _decrement_in_flight_tasks++```python+def _decrement_in_flight_tasks(self, task_id: str, context: str = ''):+```++Safely decrement the in-flight tasks counter with safety checks.+<a id="camel.societies.workforce.workforce.Workforce._cleanup_task_tracking"></a>### _cleanup_task_tracking@@ -201,6 +221,25 @@ def _decompose_task(self, task: Task):List[Task]: The subtasks.+<a id="camel.societies.workforce.workforce.Workforce._analyze_failure"></a>++### _analyze_failure++```python+def _analyze_failure(self, task: Task, error_message: str):+```++Analyze a task failure and decide on the best recovery strategy.++**Parameters:**++- **task** (Task): The failed task+- **error_message** (str): The error message from the failure++**Returns:**++ RecoveryDecision: The decided recovery strategy with reasoning+<a id="camel.societies.workforce.workforce.Workforce.pause"></a>### pause@@ -408,6 +447,20 @@ def continue_from_pause(self):Optional[Task]: The completed task if execution finishes, None ifstill running/paused.+<a id="camel.societies.workforce.workforce.Workforce._start_child_node_when_paused"></a>++### _start_child_node_when_paused++```python+def _start_child_node_when_paused(self, start_coroutine: Coroutine):+```++Helper to start a child node when workforce is paused.++**Parameters:**++- **start_coroutine**: The coroutine to start (e.g., worker_node.start())+<a id="camel.societies.workforce.workforce.Workforce.add_single_agent_worker"></a>### add_single_agent_worker@@ -422,6 +475,7 @@ def add_single_agent_worker(```Add a worker node to the workforce that uses a single agent.+Can be called when workforce is paused to dynamically add workers.**Parameters:**@@ -451,6 +505,7 @@ def add_role_playing_worker(```Add a worker node to the workforce that uses `RolePlaying` system.+Can be called when workforce is paused to dynamically add workers.**Parameters:**@@ -475,6 +530,7 @@ def add_workforce(self, workforce: Workforce):```Add a workforce node to the workforce.+Can be called when workforce is paused to dynamically add workers.**Parameters:**diff --git a/docs/reference/camel.societies.workforce.workforce_logger.md b/docs/reference/camel.societies.workforce.workforce_logger.mdnew file mode 100644index 000000000..127b70955--- /dev/null+++ b/docs/reference/camel.societies.workforce.workforce_logger.md@@ -0,0 +1,256 @@+<a id="camel.societies.workforce.workforce_logger"></a>++<a id="camel.societies.workforce.workforce_logger.WorkforceLogger"></a>++## WorkforceLogger++```python+class WorkforceLogger:+```++Logs events and metrics for a Workforce instance.++<a id="camel.societies.workforce.workforce_logger.WorkforceLogger.__init__"></a>++### __init__++```python+def __init__(self, workforce_id: str):+```++Initializes the WorkforceLogger.++**Parameters:**++- **workforce_id** (str): The unique identifier for the workforce.++<a id="camel.societies.workforce.workforce_logger.WorkforceLogger._log_event"></a>++### _log_event++```python+def _log_event(self, event_type: str, **kwargs: Any):+```++Internal method to create and store a log entry.++**Parameters:**++- **event_type** (str): The type of event being logged. **kwargs: Additional data associated with the event.++<a id="camel.societies.workforce.workforce_logger.WorkforceLogger.log_task_created"></a>++### log_task_created++```python+def log_task_created(+ self,+ task_id: str,+ description: str,+ parent_task_id: Optional[str] = None,+ task_type: Optional[str] = None,+ metadata: Optional[Dict[str, Any]] = None+):+```++Logs the creation of a new task.++<a id="camel.societies.workforce.workforce_logger.WorkforceLogger.log_task_decomposed"></a>++### log_task_decomposed++```python+def log_task_decomposed(+ self,+ parent_task_id: str,+ subtask_ids: List[str],+ metadata: Optional[Dict[str, Any]] = None+):+```++Logs the decomposition of a task into subtasks.++<a id="camel.societies.workforce.workforce_logger.WorkforceLogger.log_task_assigned"></a>++### log_task_assigned++```python+def log_task_assigned(+ self,+ task_id: str,+ worker_id: str,+ queue_time_seconds: Optional[float] = None,+ dependencies: Optional[List[str]] = None,+ metadata: Optional[Dict[str, Any]] = None+):+```++Logs the assignment of a task to a worker.++<a id="camel.societies.workforce.workforce_logger.WorkforceLogger.log_task_started"></a>++### log_task_started++```python+def log_task_started(+ self,+ task_id: str,+ worker_id: str,+ metadata: Optional[Dict[str, Any]] = None+):+```++Logs when a worker starts processing a task.++<a id="camel.societies.workforce.workforce_logger.WorkforceLogger.log_task_completed"></a>++### log_task_completed++```python+def log_task_completed(+ self,+ task_id: str,+ worker_id: str,+ result_summary: Optional[str] = None,+ processing_time_seconds: Optional[float] = None,+ token_usage: Optional[Dict[str, int]] = None,+ metadata: Optional[Dict[str, Any]] = None+):+```++Logs the successful completion of a task.++<a id="camel.societies.workforce.workforce_logger.WorkforceLogger.log_task_failed"></a>++### log_task_failed++```python+def log_task_failed(+ self,+ task_id: str,+ error_message: str,+ worker_id: Optional[str] = None,+ metadata: Optional[Dict[str, Any]] = None+):+```++Logs the failure of a task.++<a id="camel.societies.workforce.workforce_logger.WorkforceLogger.log_worker_created"></a>++### log_worker_created++```python+def log_worker_created(+ self,+ worker_id: str,+ worker_type: str,+ role: str,+ metadata: Optional[Dict[str, Any]] = None+):+```++Logs the creation of a new worker.++<a id="camel.societies.workforce.workforce_logger.WorkforceLogger.log_worker_deleted"></a>++### log_worker_deleted++```python+def log_worker_deleted(+ self,+ worker_id: str,+ reason: Optional[str] = None,+ metadata: Optional[Dict[str, Any]] = None+):+```++Logs the deletion of a worker.++<a id="camel.societies.workforce.workforce_logger.WorkforceLogger.reset_task_data"></a>++### reset_task_data++```python+def reset_task_data(self):+```++Resets logs and data related to tasks, preserving worker+information.++<a id="camel.societies.workforce.workforce_logger.WorkforceLogger.log_queue_status"></a>++### log_queue_status++```python+def log_queue_status(+ self,+ queue_name: str,+ length: int,+ pending_task_ids: Optional[List[str]] = None,+ metadata: Optional[Dict[str, Any]] = None+):+```++Logs the status of a task queue.++<a id="camel.societies.workforce.workforce_logger.WorkforceLogger.dump_to_json"></a>++### dump_to_json++```python+def dump_to_json(self, file_path: str):+```++Dumps all log entries to a JSON file.++**Parameters:**++- **file_path** (str): The path to the JSON file.++<a id="camel.societies.workforce.workforce_logger.WorkforceLogger._get_all_tasks_in_hierarchy"></a>++### _get_all_tasks_in_hierarchy++```python+def _get_all_tasks_in_hierarchy(self, task_id: str):+```++Recursively collect all tasks in the hierarchy starting from+task_id.++<a id="camel.societies.workforce.workforce_logger.WorkforceLogger._get_task_tree_string"></a>++### _get_task_tree_string++```python+def _get_task_tree_string(+ self,+ task_id: str,+ prefix: str = '',+ is_last: bool = True+):+```++Generate a string representation of the task tree.++<a id="camel.societies.workforce.workforce_logger.WorkforceLogger.get_ascii_tree_representation"></a>++### get_ascii_tree_representation++```python+def get_ascii_tree_representation(self):+```++Generates an ASCII tree representation of the current task+hierarchy and worker status.++<a id="camel.societies.workforce.workforce_logger.WorkforceLogger.get_kpis"></a>++### get_kpis++```python+def get_kpis(self):+```++Calculates and returns key performance indicators from the logs.diff --git a/docs/reference/camel.toolkits.file_write_toolkit.md b/docs/reference/camel.toolkits.file_write_toolkit.mdindex 69090340a..b1abdb08a 100644--- a/docs/reference/camel.toolkits.file_write_toolkit.md+++ b/docs/reference/camel.toolkits.file_write_toolkit.md@@ -12,8 +12,9 @@ A toolkit for creating, writing, and modifying text in files.This class provides cross-platform (macOS, Linux, Windows) support forwriting to various file formats (Markdown, DOCX, PDF, and plaintext),-replacing text in existing files, automatic backups, custom encoding,-and enhanced formatting options for specialized formats.+replacing text in existing files, automatic filename uniquification to+prevent overwrites, custom encoding and enhanced formatting options for+specialized formats.<a id="camel.toolkits.file_write_toolkit.FileWriteToolkit.__init__"></a>@@ -82,19 +83,23 @@ Write text content to a plaintext file.- **content** (str): The text content to write.- **encoding** (str): Character encoding to use. (default: :obj:`utf-8`) (default: utf-8)-<a id="camel.toolkits.file_write_toolkit.FileWriteToolkit._create_backup"></a>+<a id="camel.toolkits.file_write_toolkit.FileWriteToolkit._generate_unique_filename"></a>-### _create_backup+### _generate_unique_filename```python-def _create_backup(self, file_path: Path):+def _generate_unique_filename(self, file_path: Path):```-Create a backup of the file if it exists and backup is enabled.+Generate a unique filename if the target file already exists.**Parameters:**-- **file_path** (Path): Path to the file to backup.+- **file_path** (Path): The original file path.++**Returns:**++ Path: A unique file path that doesn't exist yet.<a id="camel.toolkits.file_write_toolkit.FileWriteToolkit._write_docx_file"></a>@@ -120,19 +125,183 @@ def _write_pdf_file(self,file_path: Path,title: str,- content: str,+ content: Union[str, List[List[str]]],use_latex: bool = False):```-Write text content to a PDF file with default formatting.+Write text content to a PDF file with LaTeX and table support.**Parameters:**- **file_path** (Path): The target file path.-- **title** (str): The title of the document.-- **content** (str): The text content to write.-- **use_latex** (bool): Whether to use LaTeX for rendering. Only Recommended for documents with mathematical formulas or complex typesetting needs. (default: :obj:`False`)+- **title** (str): The document title.+- **content** (Union[str, List[List[str]]]): The content to write. Can+- **be**: - String: Supports Markdown-style tables and LaTeX math expressions - List[List[str]]: Table data as list of rows for direct table rendering+- **use_latex** (bool): Whether to use LaTeX for math rendering. (default: :obj:`False`)++<a id="camel.toolkits.file_write_toolkit.FileWriteToolkit._process_text_content"></a>++### _process_text_content++```python+def _process_text_content(+ self,+ story,+ content: str,+ heading_style,+ body_style+):+```++Process text content and add to story.++**Parameters:**++- **story**: The reportlab story list to append to+- **content** (str): The text content to process+- **heading_style**: Style for headings+- **body_style**: Style for body text++<a id="camel.toolkits.file_write_toolkit.FileWriteToolkit._find_table_line_ranges"></a>++### _find_table_line_ranges++```python+def _find_table_line_ranges(self, lines: List[str]):+```++Find line ranges that contain markdown tables.++**Parameters:**++- **lines** (List[str]): List of lines to analyze.++**Returns:**++ List[Tuple[int, int]]: List of (start_line, end_line) tuples+for table ranges.++<a id="camel.toolkits.file_write_toolkit.FileWriteToolkit._register_chinese_font"></a>++### _register_chinese_font++```python+def _register_chinese_font(self):+```++**Returns:**++ str: The font name to use for Chinese text.++<a id="camel.toolkits.file_write_toolkit.FileWriteToolkit._parse_markdown_table"></a>++### _parse_markdown_table++```python+def _parse_markdown_table(self, lines: List[str]):+```++Parse markdown-style tables from a list of lines.++**Parameters:**++- **lines** (List[str]): List of text lines that may contain tables.++**Returns:**++ List[List[List[str]]]: List of tables, where each table is a list+of rows, and each row is a list of cells.++<a id="camel.toolkits.file_write_toolkit.FileWriteToolkit._is_table_row"></a>++### _is_table_row++```python+def _is_table_row(self, line: str):+```++Check if a line appears to be a table row.++**Parameters:**++- **line** (str): The line to check.++**Returns:**++ bool: True if the line looks like a table row.++<a id="camel.toolkits.file_write_toolkit.FileWriteToolkit._is_table_separator"></a>++### _is_table_separator++```python+def _is_table_separator(self, line: str):+```++Check if a line is a table separator (e.g., |---|---|).++**Parameters:**++- **line** (str): The line to check.++**Returns:**++ bool: True if the line is a table separator.++<a id="camel.toolkits.file_write_toolkit.FileWriteToolkit._parse_table_row"></a>++### _parse_table_row++```python+def _parse_table_row(self, line: str):+```++Parse a single table row into cells.++**Parameters:**++- **line** (str): The table row line.++**Returns:**++ List[str]: List of cell contents.++<a id="camel.toolkits.file_write_toolkit.FileWriteToolkit._create_pdf_table"></a>++### _create_pdf_table++```python+def _create_pdf_table(self, table_data: List[List[str]]):+```++Create a formatted table for PDF.++**Parameters:**++- **table_data** (List[List[str]]): Table data as list of rows.++**Returns:**++ Table: A formatted reportlab Table object.++<a id="camel.toolkits.file_write_toolkit.FileWriteToolkit._convert_markdown_to_html"></a>++### _convert_markdown_to_html++```python+def _convert_markdown_to_html(self, text: str):+```++Convert basic markdown formatting to HTML for PDF rendering.++**Parameters:**++- **text** (str): Text with markdown formatting.++**Returns:**++ str: Text with HTML formatting.<a id="camel.toolkits.file_write_toolkit.FileWriteToolkit._write_csv_file"></a>@@ -267,7 +436,7 @@ and HTML (.html, .htm).- **content** (Union[str, List[List[str]]]): The content to write to the file. Content format varies by file type: - Text formats (txt, md, html, yaml): string - CSV: string or list of lists - JSON: string or serializable object- **filename** (str): The name or path of the file. If a relative path is supplied, it is resolved to self.output_dir.- **encoding** (Optional[str]): The character encoding to use. (default: :obj: `None`)-- **use_latex** (bool): For PDF files, whether to use LaTeX rendering. Only recommended for documents with mathematical formulas or complex typesetting needs. (default: :obj:`False`)+- **use_latex** (bool): Whether to use LaTeX for math rendering. (default: :obj:`False`)**Returns:**