Skip to content

armgit / camel

Public Imported from GitHub
0

🐫 CAMEL: The first and the best multi-agent framework. Finding the Scaling Law of Agents. https://www.camel-ai.org

Auto-update documentation after merge [skip ci]

camel-docs-bot3e556a7a451b
diff --git a/docs/mintlify/reference/camel.agents.chat_agent.mdx b/docs/mintlify/reference/camel.agents.chat_agent.mdx
index 70a344909..f26e6f22a 100644
--- a/docs/mintlify/reference/camel.agents.chat_agent.mdx
+++ b/docs/mintlify/reference/camel.agents.chat_agent.mdx
@@ -231,7 +231,7 @@ Class for managing conversations of CAMEL Chat Agents.
- **message_window_size** (int, optional): The maximum number of previous messages to include in the context window. If `None`, no windowing is performed. (default: :obj:`None`)
- **token_limit** (int, optional): The maximum number of tokens in a context. The context will be automatically pruned to fulfill the limitation. If `None`, it will be set according to the backend model. (default: :obj:`None`)
- **output_language** (str, optional): The language to be output by the agent. (default: :obj:`None`)
-- **tools** (Optional[List[Union[FunctionTool, Callable]]], optional): List of available :obj:`FunctionTool` or :obj:`Callable`. (default: :obj:`None`) external_tools (Optional[List[Union[FunctionTool, Callable, Dict[str, Any]]]], optional): List of external tools (:obj:`FunctionTool` or :obj:`Callable` or :obj:`Dict[str, Any]`) bind to one chat agent. When these tools are called, the agent will directly return the request instead of processing it. (default: :obj:`None`)
+- **tools** (Optional[List[Union[FunctionTool, Callable]]], optional): List of available :obj:`FunctionTool` or :obj:`Callable`. (default: :obj:`None`) toolkits_to_register_agent (Optional[List[RegisteredAgentToolkit]], optional): List of toolkit instances that inherit from :obj:`RegisteredAgentToolkit`. The agent will register itself with these toolkits, allowing them to access the agent instance. Note: This does NOT add the toolkit's tools to the agent. To use tools from these toolkits, pass them explicitly via the `tools` parameter. (default: :obj:`None`) external_tools (Optional[List[Union[FunctionTool, Callable, Dict[str, Any]]]], optional): List of external tools (:obj:`FunctionTool` or :obj:`Callable` or :obj:`Dict[str, Any]`) bind to one chat agent. When these tools are called, the agent will directly return the request instead of processing it. (default: :obj:`None`)
- **response_terminators** (List[ResponseTerminator], optional): List of :obj:`ResponseTerminator` bind to one chat agent. (default: :obj:`None`)
- **scheduling_strategy** (str): name of function that defines how to select the next model in ModelManager. (default: :str:`round_robin`)
- **max_iteration** (Optional[int], optional): Maximum number of model calling iterations allowed per step. If `None` (default), there's no explicit limit. If `1`, it performs a single model call. If `N > 1`, it allows up to N model calls. (default: :obj:`None`)
@@ -256,6 +256,7 @@ def __init__(
token_limit: Optional[int] = None,
output_language: Optional[str] = None,
tools: Optional[List[Union[FunctionTool, Callable]]] = None,
+ toolkits_to_register_agent: Optional[List[RegisteredAgentToolkit]] = None,
external_tools: Optional[List[Union[FunctionTool, Callable, Dict[str, Any]]]] = None,
response_terminators: Optional[List[ResponseTerminator]] = None,
scheduling_strategy: str = 'round_robin',
@@ -777,18 +778,6 @@ def _convert_to_chatagent_response(
Parse the final model response into the chat agent response.
-<a id="camel.agents.chat_agent.ChatAgent._process_pending_images"></a>
-
-### _process_pending_images
-
-```python
-def _process_pending_images(self):
-```
-
-**Returns:**
-
- List: List of successfully converted PIL Images.
-
<a id="camel.agents.chat_agent.ChatAgent._record_final_output"></a>
### _record_final_output
@@ -799,37 +788,6 @@ def _record_final_output(self, output_messages: List[BaseMessage]):
Log final messages or warnings about multiple responses.
-<a id="camel.agents.chat_agent.ChatAgent._is_vision_error"></a>
-
-### _is_vision_error
-
-```python
-def _is_vision_error(self, exc: Exception):
-```
-
-Check if the exception is likely related to vision/image is not
-supported by the model.
-
-<a id="camel.agents.chat_agent.ChatAgent._has_images"></a>
-
-### _has_images
-
-```python
-def _has_images(self, messages: List[OpenAIMessage]):
-```
-
-Check if any message contains images.
-
-<a id="camel.agents.chat_agent.ChatAgent._strip_images_from_messages"></a>
-
-### _strip_images_from_messages
-
-```python
-def _strip_images_from_messages(self, messages: List[OpenAIMessage]):
-```
-
-Remove images from messages, keeping only text content.
-
<a id="camel.agents.chat_agent.ChatAgent._get_model_response"></a>
### _get_model_response
diff --git a/docs/mintlify/reference/camel.toolkits.base.mdx b/docs/mintlify/reference/camel.toolkits.base.mdx
index 646e8d00e..72fb98d87 100644
--- a/docs/mintlify/reference/camel.toolkits.base.mdx
+++ b/docs/mintlify/reference/camel.toolkits.base.mdx
@@ -56,3 +56,62 @@ Run the MCP server in the specified mode.
**Parameters:**
- **mode** (`Literal["stdio", "sse", "streamable-http"]`): The mode to run the MCP server in.
+
+<a id="camel.toolkits.base.RegisteredAgentToolkit"></a>
+
+## RegisteredAgentToolkit
+
+```python
+class RegisteredAgentToolkit:
+```
+
+Mixin class for toolkits that need to register a ChatAgent.
+
+This mixin provides a standard interface for toolkits that require
+a reference to a ChatAgent instance. The ChatAgent will check if a
+toolkit has this mixin and automatically register itself.
+
+<a id="camel.toolkits.base.RegisteredAgentToolkit.__init__"></a>
+
+### __init__
+
+```python
+def __init__(self):
+```
+
+<a id="camel.toolkits.base.RegisteredAgentToolkit.agent"></a>
+
+### agent
+
+```python
+def agent(self):
+```
+
+**Returns:**
+
+ Optional[ChatAgent]: The registered agent, or None if not
+registered.
+
+**Note:**
+
+If None is returned, it means the toolkit has not been registered
+with a ChatAgent yet. Make sure to pass this toolkit to a ChatAgent
+via the toolkits parameter during initialization.
+
+<a id="camel.toolkits.base.RegisteredAgentToolkit.register_agent"></a>
+
+### register_agent
+
+```python
+def register_agent(self, agent: 'ChatAgent'):
+```
+
+Register a ChatAgent with this toolkit.
+
+This method allows registering an agent after initialization. The
+ChatAgent will automatically call this method if the toolkit to
+register inherits from RegisteredAgentToolkit.
+
+**Parameters:**
+
+- **agent** (ChatAgent): The ChatAgent instance to register.
diff --git a/docs/mintlify/reference/camel.toolkits.screenshot_toolkit.mdx b/docs/mintlify/reference/camel.toolkits.screenshot_toolkit.mdx
index 8b0214880..9601355d2 100644
--- a/docs/mintlify/reference/camel.toolkits.screenshot_toolkit.mdx
+++ b/docs/mintlify/reference/camel.toolkits.screenshot_toolkit.mdx
@@ -5,7 +5,7 @@
## ScreenshotToolkit
```python
-class ScreenshotToolkit(BaseToolkit):
+class ScreenshotToolkit(BaseToolkit, RegisteredAgentToolkit):
```
A toolkit for taking screenshots.
@@ -29,27 +29,62 @@ Initializes the ScreenshotToolkit.
- **working_directory** (str, optional): The directory path where notes will be stored. If not provided, it will be determined by the `CAMEL_WORKDIR` environment variable (if set). If the environment variable is not set, it defaults to `camel_working_dir`.
- **timeout** (Optional[float]): Timeout for API requests in seconds. (default: :obj:`None`)
-<a id="camel.toolkits.screenshot_toolkit.ScreenshotToolkit.take_screenshot"></a>
+<a id="camel.toolkits.screenshot_toolkit.ScreenshotToolkit.read_image"></a>
-### take_screenshot
+### read_image
```python
-def take_screenshot(self, save_to_file: bool = True):
+def read_image(self, image_path: str, instruction: str = ''):
```
-Take a screenshot of the entire screen and return it as a
-base64-encoded image.
+Analyzes an image from a local file path.
+
+This function enables you to "see" and interpret an image from a
+file. It's useful for tasks where you need to understand visual
+information, such as reading a screenshot of a webpage or a diagram.
+
+**Parameters:**
+
+- **image_path** (str): The local file path to the image. For example: 'screenshots/login_page.png'.
+- **instruction** (str, optional): Specific instructions for what to look for or what to do with the image. For example: "What is the main headline on this page?" or "Find the 'Submit' button.".
+
+**Returns:**
+
+ str: The response after analyzing the image, which could be a
+description, an answer, or a confirmation of an action.
+
+<a id="camel.toolkits.screenshot_toolkit.ScreenshotToolkit.take_screenshot_and_read_image"></a>
+
+### take_screenshot_and_read_image
+
+```python
+def take_screenshot_and_read_image(
+ self,
+ filename: str,
+ save_to_file: bool = True,
+ read_image: bool = True,
+ instruction: Optional[str] = None
+):
+```
+
+Captures a screenshot of the entire screen.
+
+This function can save the screenshot to a file and optionally analyze
+it. It's useful for capturing the current state of the UI for
+documentation, analysis, or to guide subsequent actions.
**Parameters:**
-- **save_to_file** (bool): Whether to save the screenshot to a file. (default: :obj:`True`)
+- **filename** (str): The name for the screenshot file (e.g., "homepage.png"). The file is saved in a `screenshots` subdirectory within the working directory. Must end with `.png`. (default: :obj:`None`)
+- **save_to_file** (bool, optional): If `True`, saves the screenshot to a file. (default: :obj:`True`)
+- **read_image** (bool, optional): If `True`, the agent will analyze the screenshot. `save_to_file` must also be `True`. (default: :obj:`True`)
+- **instruction** (Optional[str], optional): A specific question or command for the agent regarding the screenshot, used only if `read_image` is `True`. For example: "Confirm that the user is logged in.".
**Returns:**
- ToolResult: An object containing:
-- text (str): A description of the screenshot.
-- images (List[str]): A list containing one base64-encoded
-PNG image data URL.
+ str: A confirmation message indicating success or failure,
+including the file path if saved, and the agent's response
+if `read_image` is `True`.
<a id="camel.toolkits.screenshot_toolkit.ScreenshotToolkit.get_tools"></a>