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.
- camel/__init__.py +1 -1
- camel/agents/chat_agent.py +1533 -135
- camel/agents/repo_agent.py +2 -1
- camel/benchmarks/browsecomp.py +6 -6
- camel/logger.py +1 -1
- camel/messages/base.py +12 -1
- camel/models/azure_openai_model.py +96 -7
- camel/models/base_model.py +68 -10
- camel/models/deepseek_model.py +5 -0
- camel/models/gemini_model.py +5 -0
- camel/models/litellm_model.py +48 -16
- camel/models/model_manager.py +24 -6
- camel/models/openai_compatible_model.py +109 -5
- camel/models/openai_model.py +117 -8
- camel/societies/workforce/prompts.py +68 -5
- camel/societies/workforce/role_playing_worker.py +65 -7
- camel/societies/workforce/single_agent_worker.py +72 -18
- camel/societies/workforce/structured_output_handler.py +500 -0
- camel/societies/workforce/utils.py +67 -2
- camel/societies/workforce/workforce.py +527 -114
- camel/societies/workforce/workforce_logger.py +0 -8
- camel/tasks/task.py +3 -1
- camel/toolkits/__init__.py +2 -0
- camel/toolkits/file_write_toolkit.py +526 -121
- camel/toolkits/hybrid_browser_toolkit/actions.py +235 -60
- camel/toolkits/hybrid_browser_toolkit/agent.py +25 -8
- camel/toolkits/hybrid_browser_toolkit/browser_session.py +574 -164
- camel/toolkits/hybrid_browser_toolkit/hybrid_browser_toolkit.py +996 -126
- camel/toolkits/hybrid_browser_toolkit/stealth_config.py +116 -0
- camel/toolkits/hybrid_browser_toolkit/stealth_script.js +0 -0
- camel/toolkits/message_agent_toolkit.py +608 -0
- camel/toolkits/note_taking_toolkit.py +7 -13
- {camel_ai-0.2.71a4.dist-info → camel_ai-0.2.71a6.dist-info}/METADATA +6 -4
- {camel_ai-0.2.71a4.dist-info → camel_ai-0.2.71a6.dist-info}/RECORD +36 -32
- {camel_ai-0.2.71a4.dist-info → camel_ai-0.2.71a6.dist-info}/WHEEL +0 -0
- {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,
|