camel-ai 0.2.71a4__py3-none-any.whl → 0.2.71a6__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 (36) hide show
  1. camel/__init__.py +1 -1
  2. camel/agents/chat_agent.py +1533 -135
  3. camel/agents/repo_agent.py +2 -1
  4. camel/benchmarks/browsecomp.py +6 -6
  5. camel/logger.py +1 -1
  6. camel/messages/base.py +12 -1
  7. camel/models/azure_openai_model.py +96 -7
  8. camel/models/base_model.py +68 -10
  9. camel/models/deepseek_model.py +5 -0
  10. camel/models/gemini_model.py +5 -0
  11. camel/models/litellm_model.py +48 -16
  12. camel/models/model_manager.py +24 -6
  13. camel/models/openai_compatible_model.py +109 -5
  14. camel/models/openai_model.py +117 -8
  15. camel/societies/workforce/prompts.py +68 -5
  16. camel/societies/workforce/role_playing_worker.py +65 -7
  17. camel/societies/workforce/single_agent_worker.py +72 -18
  18. camel/societies/workforce/structured_output_handler.py +500 -0
  19. camel/societies/workforce/utils.py +67 -2
  20. camel/societies/workforce/workforce.py +527 -114
  21. camel/societies/workforce/workforce_logger.py +0 -8
  22. camel/tasks/task.py +3 -1
  23. camel/toolkits/__init__.py +2 -0
  24. camel/toolkits/file_write_toolkit.py +526 -121
  25. camel/toolkits/hybrid_browser_toolkit/actions.py +235 -60
  26. camel/toolkits/hybrid_browser_toolkit/agent.py +25 -8
  27. camel/toolkits/hybrid_browser_toolkit/browser_session.py +574 -164
  28. camel/toolkits/hybrid_browser_toolkit/hybrid_browser_toolkit.py +996 -126
  29. camel/toolkits/hybrid_browser_toolkit/stealth_config.py +116 -0
  30. camel/toolkits/hybrid_browser_toolkit/stealth_script.js +0 -0
  31. camel/toolkits/message_agent_toolkit.py +608 -0
  32. camel/toolkits/note_taking_toolkit.py +7 -13
  33. {camel_ai-0.2.71a4.dist-info → camel_ai-0.2.71a6.dist-info}/METADATA +6 -4
  34. {camel_ai-0.2.71a4.dist-info → camel_ai-0.2.71a6.dist-info}/RECORD +36 -32
  35. {camel_ai-0.2.71a4.dist-info → camel_ai-0.2.71a6.dist-info}/WHEEL +0 -0
  36. {camel_ai-0.2.71a4.dist-info → camel_ai-0.2.71a6.dist-info}/licenses/LICENSE +0 -0
@@ -11,10 +11,11 @@
11
11
  # See the License for the specific language governing permissions and
12
12
  # limitations under the License.
13
13
  # ========= Copyright 2023-2024 @ CAMEL-AI.org. All Rights Reserved. =========
14
+ from enum import Enum
14
15
  from functools import wraps
15
- from typing import Callable, List
16
+ from typing import Callable, List, Optional
16
17
 
17
- from pydantic import BaseModel, Field
18
+ from pydantic import BaseModel, Field, field_validator
18
19
 
19
20
 
20
21
  class WorkerConf(BaseModel):
@@ -54,6 +55,23 @@ class TaskAssignment(BaseModel):
54
55
  "This is critical for the task decomposition and execution.",
55
56
  )
56
57
 
58
+ # Allow LLMs to output dependencies as a comma-separated string or empty
59
+ # string. This validator converts such cases into a list[str] so that
60
+ # downstream logic does not break with validation errors.
61
+ @staticmethod
62
+ def _split_and_strip(dep_str: str) -> List[str]:
63
+ r"""Utility to split a comma separated string and strip whitespace."""
64
+ return [d.strip() for d in dep_str.split(',') if d.strip()]
65
+
66
+ @field_validator("dependencies", mode="before")
67
+ def validate_dependencies(cls, v) -> List[str]:
68
+ if v is None:
69
+ return []
70
+ # Handle empty string or comma-separated string from LLM
71
+ if isinstance(v, str):
72
+ return TaskAssignment._split_and_strip(v)
73
+ return v
74
+
57
75
 
58
76
  class TaskAssignResult(BaseModel):
59
77
  r"""The result of task assignment for both single and batch assignments."""
@@ -63,6 +81,53 @@ class TaskAssignResult(BaseModel):
63
81
  )
64
82
 
65
83
 
84
+ class RecoveryStrategy(str, Enum):
85
+ r"""Strategies for handling failed tasks."""
86
+
87
+ RETRY = "retry"
88
+ REPLAN = "replan"
89
+ DECOMPOSE = "decompose"
90
+ CREATE_WORKER = "create_worker"
91
+
92
+ def __str__(self):
93
+ return self.value
94
+
95
+ def __repr__(self):
96
+ return f"RecoveryStrategy.{self.name}"
97
+
98
+
99
+ class FailureContext(BaseModel):
100
+ r"""Context information about a task failure."""
101
+
102
+ task_id: str = Field(description="ID of the failed task")
103
+ task_content: str = Field(description="Content of the failed task")
104
+ failure_count: int = Field(
105
+ description="Number of times this task has failed"
106
+ )
107
+ error_message: str = Field(description="Detailed error message")
108
+ worker_id: Optional[str] = Field(
109
+ default=None, description="ID of the worker that failed"
110
+ )
111
+ task_depth: int = Field(
112
+ description="Depth of the task in the decomposition hierarchy"
113
+ )
114
+ additional_info: Optional[str] = Field(
115
+ default=None, description="Additional context about the task"
116
+ )
117
+
118
+
119
+ class RecoveryDecision(BaseModel):
120
+ r"""Decision on how to recover from a task failure."""
121
+
122
+ strategy: RecoveryStrategy = Field(
123
+ description="The chosen recovery strategy"
124
+ )
125
+ reasoning: str = Field(description="Explanation for the chosen strategy")
126
+ modified_task_content: Optional[str] = Field(
127
+ default=None, description="Modified task content if strategy is REPLAN"
128
+ )
129
+
130
+
66
131
  def check_if_running(
67
132
  running: bool,
68
133
  max_retries: int = 3,