camel-ai 0.2.72a8__py3-none-any.whl → 0.2.73a0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of camel-ai might be problematic. Click here for more details.

Files changed (37) hide show
  1. camel/__init__.py +1 -1
  2. camel/agents/chat_agent.py +113 -338
  3. camel/memories/agent_memories.py +18 -17
  4. camel/societies/workforce/prompts.py +10 -4
  5. camel/societies/workforce/single_agent_worker.py +7 -5
  6. camel/toolkits/__init__.py +4 -1
  7. camel/toolkits/base.py +57 -1
  8. camel/toolkits/hybrid_browser_toolkit/config_loader.py +136 -413
  9. camel/toolkits/hybrid_browser_toolkit/hybrid_browser_toolkit.py +796 -1631
  10. camel/toolkits/hybrid_browser_toolkit/ts/package-lock.json +4356 -0
  11. camel/toolkits/hybrid_browser_toolkit/ts/package.json +33 -0
  12. camel/toolkits/hybrid_browser_toolkit/ts/src/browser-scripts.js +125 -0
  13. camel/toolkits/hybrid_browser_toolkit/ts/src/browser-session.ts +916 -0
  14. camel/toolkits/hybrid_browser_toolkit/ts/src/config-loader.ts +226 -0
  15. camel/toolkits/hybrid_browser_toolkit/ts/src/hybrid-browser-toolkit.ts +522 -0
  16. camel/toolkits/hybrid_browser_toolkit/ts/src/index.ts +7 -0
  17. camel/toolkits/hybrid_browser_toolkit/ts/src/types.ts +110 -0
  18. camel/toolkits/hybrid_browser_toolkit/ts/tsconfig.json +26 -0
  19. camel/toolkits/hybrid_browser_toolkit/ts/websocket-server.js +210 -0
  20. camel/toolkits/hybrid_browser_toolkit/ws_wrapper.py +533 -0
  21. camel/toolkits/message_integration.py +592 -0
  22. camel/toolkits/note_taking_toolkit.py +18 -29
  23. camel/toolkits/screenshot_toolkit.py +116 -31
  24. camel/toolkits/search_toolkit.py +20 -2
  25. camel/toolkits/terminal_toolkit.py +16 -2
  26. camel/toolkits/video_analysis_toolkit.py +13 -13
  27. camel/toolkits/video_download_toolkit.py +11 -11
  28. {camel_ai-0.2.72a8.dist-info → camel_ai-0.2.73a0.dist-info}/METADATA +10 -4
  29. {camel_ai-0.2.72a8.dist-info → camel_ai-0.2.73a0.dist-info}/RECORD +31 -25
  30. camel/toolkits/hybrid_browser_toolkit/actions.py +0 -417
  31. camel/toolkits/hybrid_browser_toolkit/agent.py +0 -311
  32. camel/toolkits/hybrid_browser_toolkit/browser_session.py +0 -740
  33. camel/toolkits/hybrid_browser_toolkit/snapshot.py +0 -227
  34. camel/toolkits/hybrid_browser_toolkit/stealth_script.js +0 -0
  35. camel/toolkits/hybrid_browser_toolkit/unified_analyzer.js +0 -1002
  36. {camel_ai-0.2.72a8.dist-info → camel_ai-0.2.73a0.dist-info}/WHEEL +0 -0
  37. {camel_ai-0.2.72a8.dist-info → camel_ai-0.2.73a0.dist-info}/licenses/LICENSE +0 -0
@@ -206,8 +206,9 @@ TASK_DECOMPOSE_PROMPT = r"""You need to decompose the given task into subtasks a
206
206
  * **DO NOT** use vague verbs like "analyze," "look into," or "research" without defining the output.
207
207
  * **DO** specify the format and content of the output. For example, instead of "Analyze the attached report," write "Summarize the key findings of the attached report in a 3-bullet-point list." Instead of "Find contacts," write "Extract all names and email addresses from the document and return them as a JSON list of objects, where each object has a 'name' and 'email' key."
208
208
 
209
- 3. **Strategic Grouping for Sequential Work**:
210
- * If a series of steps must be done in order *and* can be handled by the same worker type, group them into a single subtask to maintain flow and minimize handoffs.
209
+ 3. **Full Workflow Completion & Strategic Grouping**:
210
+ * **Preserve the Entire Goal**: Ensure the decomposed subtasks collectively achieve the *entire* original task. Do not drop or ignore final steps like sending a message, submitting a form, or creating a file.
211
+ * **Group Sequential Actions**: If a series of steps must be done in order *and* can be handled by the same worker type (e.g., read, think, reply), group them into a single, comprehensive subtask. This maintains workflow and ensures the final goal is met.
211
212
 
212
213
  4. **Aggressive Parallelization**:
213
214
  * **Across Different Worker Specializations**: If distinct phases of the overall task require different types of workers (e.g., research by a 'SearchAgent', then content creation by a 'DocumentAgent'), define these as separate subtasks.
@@ -316,6 +317,8 @@ Additional Info: {additional_info}
316
317
  2. **REPLAN**: Modify the task content to address the underlying issue
317
318
  - Use for: Unclear requirements, insufficient context, correctable errors
318
319
  - Provide: Modified task content that addresses the failure cause
320
+ - **CRITICAL**: The replanned task MUST be a clear, actionable
321
+ instruction for an AI agent, not a question or request for a human.
319
322
 
320
323
  3. **DECOMPOSE**: Break the task into smaller, more manageable subtasks
321
324
  - Use for: Complex tasks, capability mismatches, persistent failures
@@ -328,10 +331,13 @@ Additional Info: {additional_info}
328
331
 
329
332
  - **Connection/Network Errors**: Almost always choose RETRY
330
333
  - **Model Processing Errors**: Consider REPLAN if the task can be clarified, otherwise DECOMPOSE
331
- - **Capability Gaps**: Choose DECOMPOSE to break into simpler parts
334
+ - **Capability Gaps**: Choose DECOMPOSE to break into simpler parts. If a
335
+ replan can work, ensure the new task is a command for an agent, not a
336
+ request to a user.
332
337
  - **Ambiguous Requirements**: Choose REPLAN with clearer instructions
333
338
  - **High Failure Count**: Lean towards DECOMPOSE rather than repeated retries
334
- - **Deep Tasks (depth > 2)**: Prefer RETRY or REPLAN over further decomposition
339
+ - **Deep Tasks (depth > 2)**: Prefer RETRY or REPLAN over further
340
+ decomposition
335
341
 
336
342
  **RESPONSE FORMAT:**
337
343
  You must return a valid JSON object with these fields:
@@ -410,11 +410,13 @@ class SingleAgentWorker(Worker):
410
410
  f"{getattr(worker_agent, 'agent_id', worker_agent.role_name)} "
411
411
  f"(from pool/clone of "
412
412
  f"{getattr(self.worker, 'agent_id', self.worker.role_name)}) "
413
- f"to process task {task.content}",
414
- "response_content": response_content,
415
- "tool_calls": final_response.info.get("tool_calls")
416
- if isinstance(response, AsyncStreamingChatAgentResponse)
417
- else response.info.get("tool_calls"),
413
+ f"to process task: {task.content}",
414
+ "response_content": response_content[:50],
415
+ "tool_calls": str(
416
+ final_response.info.get("tool_calls")
417
+ if isinstance(response, AsyncStreamingChatAgentResponse)
418
+ else response.info.get("tool_calls")
419
+ )[:50],
418
420
  "total_tokens": total_tokens,
419
421
  }
420
422
 
@@ -31,7 +31,7 @@ from .meshy_toolkit import MeshyToolkit
31
31
  from .openbb_toolkit import OpenBBToolkit
32
32
  from .bohrium_toolkit import BohriumToolkit
33
33
 
34
- from .base import BaseToolkit
34
+ from .base import BaseToolkit, RegisteredAgentToolkit
35
35
  from .google_maps_toolkit import GoogleMapsToolkit
36
36
  from .code_execution import CodeExecutionToolkit
37
37
  from .github_toolkit import GithubToolkit
@@ -87,6 +87,7 @@ from .note_taking_toolkit import NoteTakingToolkit
87
87
  from .message_agent_toolkit import AgentCommunicationToolkit
88
88
  from .web_deploy_toolkit import WebDeployToolkit
89
89
  from .screenshot_toolkit import ScreenshotToolkit
90
+ from .message_integration import ToolkitMessageIntegration
90
91
 
91
92
  __all__ = [
92
93
  'BaseToolkit',
@@ -162,4 +163,6 @@ __all__ = [
162
163
  'AgentCommunicationToolkit',
163
164
  'WebDeployToolkit',
164
165
  'ScreenshotToolkit',
166
+ 'RegisteredAgentToolkit',
167
+ 'ToolkitMessageIntegration',
165
168
  ]
camel/toolkits/base.py CHANGED
@@ -12,11 +12,18 @@
12
12
  # limitations under the License.
13
13
  # ========= Copyright 2023-2024 @ CAMEL-AI.org. All Rights Reserved. =========
14
14
 
15
- from typing import List, Literal, Optional
15
+ from typing import TYPE_CHECKING, List, Literal, Optional
16
16
 
17
+ from camel.logger import get_logger
17
18
  from camel.toolkits import FunctionTool
18
19
  from camel.utils import AgentOpsMeta, with_timeout
19
20
 
21
+ if TYPE_CHECKING:
22
+ from camel.agents import ChatAgent
23
+
24
+
25
+ logger = get_logger(__name__)
26
+
20
27
 
21
28
  class BaseToolkit(metaclass=AgentOpsMeta):
22
29
  r"""Base class for toolkits.
@@ -63,3 +70,52 @@ class BaseToolkit(metaclass=AgentOpsMeta):
63
70
  the MCP server in.
64
71
  """
65
72
  self.mcp.run(mode)
73
+
74
+
75
+ class RegisteredAgentToolkit:
76
+ r"""Mixin class for toolkits that need to register a ChatAgent.
77
+
78
+ This mixin provides a standard interface for toolkits that require
79
+ a reference to a ChatAgent instance. The ChatAgent will check if a
80
+ toolkit has this mixin and automatically register itself.
81
+ """
82
+
83
+ def __init__(self):
84
+ self._agent: Optional["ChatAgent"] = None
85
+
86
+ @property
87
+ def agent(self) -> Optional["ChatAgent"]:
88
+ r"""Get the registered ChatAgent instance.
89
+
90
+ Returns:
91
+ Optional[ChatAgent]: The registered agent, or None if not
92
+ registered.
93
+
94
+ Note:
95
+ If None is returned, it means the toolkit has not been registered
96
+ with a ChatAgent yet. Make sure to pass this toolkit to a ChatAgent
97
+ via the toolkits parameter during initialization.
98
+ """
99
+ if self._agent is None:
100
+ logger.warning(
101
+ f"{self.__class__.__name__} does not have a "
102
+ f"registered ChatAgent. "
103
+ f"Please ensure this toolkit is passed to a ChatAgent via the "
104
+ f"'toolkits_to_register_agent' parameter during ChatAgent "
105
+ f"initialization if you want to use the tools that require a "
106
+ f"registered agent."
107
+ )
108
+ return self._agent
109
+
110
+ def register_agent(self, agent: "ChatAgent") -> None:
111
+ r"""Register a ChatAgent with this toolkit.
112
+
113
+ This method allows registering an agent after initialization. The
114
+ ChatAgent will automatically call this method if the toolkit to
115
+ register inherits from RegisteredAgentToolkit.
116
+
117
+ Args:
118
+ agent (ChatAgent): The ChatAgent instance to register.
119
+ """
120
+ self._agent = agent
121
+ logger.info(f"Agent registered with {self.__class__.__name__}")