camel-ai 0.2.76a3__py3-none-any.whl → 0.2.76a4__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/societies/workforce/workforce.py +51 -2
- camel/utils/context_utils.py +52 -0
- {camel_ai-0.2.76a3.dist-info → camel_ai-0.2.76a4.dist-info}/METADATA +1 -1
- {camel_ai-0.2.76a3.dist-info → camel_ai-0.2.76a4.dist-info}/RECORD +7 -7
- {camel_ai-0.2.76a3.dist-info → camel_ai-0.2.76a4.dist-info}/WHEEL +0 -0
- {camel_ai-0.2.76a3.dist-info → camel_ai-0.2.76a4.dist-info}/licenses/LICENSE +0 -0
camel/__init__.py
CHANGED
|
@@ -2075,8 +2075,40 @@ class Workforce(BaseNode):
|
|
|
2075
2075
|
TaskAssignResult: Assignment result containing task assignments
|
|
2076
2076
|
with their dependencies.
|
|
2077
2077
|
"""
|
|
2078
|
+
# Wait for workers to be ready before assignment with exponential
|
|
2079
|
+
# backoff
|
|
2080
|
+
worker_readiness_timeout = 2.0 # Maximum wait time in seconds
|
|
2081
|
+
worker_readiness_check_interval = 0.05 # Initial check interval
|
|
2082
|
+
start_time = time.time()
|
|
2083
|
+
check_interval = worker_readiness_check_interval
|
|
2084
|
+
backoff_multiplier = 1.5 # Exponential backoff factor
|
|
2085
|
+
max_interval = 0.5 # Cap the maximum interval
|
|
2086
|
+
|
|
2087
|
+
while (time.time() - start_time) < worker_readiness_timeout:
|
|
2088
|
+
valid_worker_ids = self._get_valid_worker_ids()
|
|
2089
|
+
if len(valid_worker_ids) > 0:
|
|
2090
|
+
elapsed = time.time() - start_time
|
|
2091
|
+
logger.debug(
|
|
2092
|
+
f"Workers ready after {elapsed:.3f}s: "
|
|
2093
|
+
f"{len(valid_worker_ids)} workers available"
|
|
2094
|
+
)
|
|
2095
|
+
break
|
|
2096
|
+
|
|
2097
|
+
await asyncio.sleep(check_interval)
|
|
2098
|
+
# Exponential backoff with cap
|
|
2099
|
+
check_interval = min(
|
|
2100
|
+
check_interval * backoff_multiplier, max_interval
|
|
2101
|
+
)
|
|
2102
|
+
else:
|
|
2103
|
+
# Timeout reached, log warning but continue
|
|
2104
|
+
logger.warning(
|
|
2105
|
+
f"Worker readiness timeout after "
|
|
2106
|
+
f"{worker_readiness_timeout}s, "
|
|
2107
|
+
f"proceeding with {len(self._children)} children"
|
|
2108
|
+
)
|
|
2109
|
+
valid_worker_ids = self._get_valid_worker_ids()
|
|
2110
|
+
|
|
2078
2111
|
self.coordinator_agent.reset()
|
|
2079
|
-
valid_worker_ids = self._get_valid_worker_ids()
|
|
2080
2112
|
|
|
2081
2113
|
logger.debug(
|
|
2082
2114
|
f"Sending batch assignment request to coordinator "
|
|
@@ -2110,7 +2142,24 @@ class Workforce(BaseNode):
|
|
|
2110
2142
|
invalid_assignments, tasks, valid_worker_ids
|
|
2111
2143
|
)
|
|
2112
2144
|
)
|
|
2113
|
-
|
|
2145
|
+
|
|
2146
|
+
# Combine assignments with deduplication, prioritizing retry results
|
|
2147
|
+
assignment_map = {a.task_id: a for a in valid_assignments}
|
|
2148
|
+
assignment_map.update(
|
|
2149
|
+
{a.task_id: a for a in retry_and_fallback_assignments}
|
|
2150
|
+
)
|
|
2151
|
+
all_assignments = list(assignment_map.values())
|
|
2152
|
+
|
|
2153
|
+
# Log any overwrites for debugging
|
|
2154
|
+
valid_task_ids = {a.task_id for a in valid_assignments}
|
|
2155
|
+
retry_task_ids = {a.task_id for a in retry_and_fallback_assignments}
|
|
2156
|
+
overlap_task_ids = valid_task_ids & retry_task_ids
|
|
2157
|
+
|
|
2158
|
+
if overlap_task_ids:
|
|
2159
|
+
logger.warning(
|
|
2160
|
+
f"Retry assignments overrode {len(overlap_task_ids)} "
|
|
2161
|
+
f"valid assignments for tasks: {sorted(overlap_task_ids)}"
|
|
2162
|
+
)
|
|
2114
2163
|
|
|
2115
2164
|
# Update Task.dependencies for all final assignments
|
|
2116
2165
|
self._update_task_dependencies_from_assignments(all_assignments, tasks)
|
camel/utils/context_utils.py
CHANGED
|
@@ -393,3 +393,55 @@ class ContextUtility:
|
|
|
393
393
|
str: The session ID.
|
|
394
394
|
"""
|
|
395
395
|
return self.session_id
|
|
396
|
+
|
|
397
|
+
def load_markdown_context_to_memory(
|
|
398
|
+
self, agent: "ChatAgent", filename: str
|
|
399
|
+
) -> str:
|
|
400
|
+
r"""Load context from a markdown file and append it to agent memory.
|
|
401
|
+
Preserves existing conversation history without wiping it.
|
|
402
|
+
|
|
403
|
+
Args:
|
|
404
|
+
agent (ChatAgent): The agent to append context to.
|
|
405
|
+
filename (str): Name of the markdown file (without .md extension).
|
|
406
|
+
|
|
407
|
+
Returns:
|
|
408
|
+
str: Status message indicating success or failure with details.
|
|
409
|
+
"""
|
|
410
|
+
try:
|
|
411
|
+
content = self.load_markdown_file(filename)
|
|
412
|
+
|
|
413
|
+
if not content.strip():
|
|
414
|
+
return f"Context file not found or empty: {filename}"
|
|
415
|
+
|
|
416
|
+
from camel.messages import BaseMessage
|
|
417
|
+
from camel.types import OpenAIBackendRole
|
|
418
|
+
|
|
419
|
+
prefix_prompt = (
|
|
420
|
+
"The following is the context from a previous "
|
|
421
|
+
"session or workflow. This information might help you "
|
|
422
|
+
"understand the background, choose which tools to use, "
|
|
423
|
+
"and plan your next steps."
|
|
424
|
+
)
|
|
425
|
+
|
|
426
|
+
# TODO: change to system message once multi-system-message
|
|
427
|
+
# is supported
|
|
428
|
+
context_message = BaseMessage.make_assistant_message(
|
|
429
|
+
role_name="Assistant",
|
|
430
|
+
content=f"{prefix_prompt}\n\n{content}",
|
|
431
|
+
)
|
|
432
|
+
|
|
433
|
+
agent.update_memory(context_message, OpenAIBackendRole.USER)
|
|
434
|
+
|
|
435
|
+
char_count = len(content)
|
|
436
|
+
log_msg = (
|
|
437
|
+
f"Context appended to agent {agent.agent_id} "
|
|
438
|
+
f"({char_count} characters)"
|
|
439
|
+
)
|
|
440
|
+
logger.info(log_msg)
|
|
441
|
+
|
|
442
|
+
return log_msg
|
|
443
|
+
|
|
444
|
+
except Exception as e:
|
|
445
|
+
error_msg = f"Failed to load markdown context to memory: {e}"
|
|
446
|
+
logger.error(error_msg)
|
|
447
|
+
return error_msg
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
camel/__init__.py,sha256=
|
|
1
|
+
camel/__init__.py,sha256=VEPqtodQz0M5XRxGR-gpj2ZYNaBX-IYXD71NCkHVyn4,901
|
|
2
2
|
camel/generators.py,sha256=JRqj9_m1PF4qT6UtybzTQ-KBT9MJQt18OAAYvQ_fr2o,13844
|
|
3
3
|
camel/human.py,sha256=Xg8x1cS5KK4bQ1SDByiHZnzsRpvRP-KZViNvmu38xo4,5475
|
|
4
4
|
camel/logger.py,sha256=WgEwael_eT6D-lVAKHpKIpwXSTjvLbny5jbV1Ab8lnA,5760
|
|
@@ -285,7 +285,7 @@ camel/societies/workforce/structured_output_handler.py,sha256=xr8szFN86hg3jQ825a
|
|
|
285
285
|
camel/societies/workforce/task_channel.py,sha256=TXRwiqtmRPdelEmFCVN3jhd5XpgaSLwy9uHPtGecujA,11418
|
|
286
286
|
camel/societies/workforce/utils.py,sha256=THgNHSeZsNVnjTzQTur3qCJhi72MrDS8X2gPET174cI,8434
|
|
287
287
|
camel/societies/workforce/worker.py,sha256=MtUqYkTC9V-PIIRwSkKiB9w_YSu92iOpoha2rktEiQ0,6248
|
|
288
|
-
camel/societies/workforce/workforce.py,sha256=
|
|
288
|
+
camel/societies/workforce/workforce.py,sha256=m5m2d2aZdKlxek8xTDrPHqvur9rg5LGYcUecZrR0ym8,144628
|
|
289
289
|
camel/societies/workforce/workforce_logger.py,sha256=0YT__ys48Bgn0IICKIZBmSWhON-eA1KShebjCdn5ppE,24525
|
|
290
290
|
camel/storages/__init__.py,sha256=RwpEyvxpMbJzVDZJJygeBg4AzyYMkTjjkfB53hTuqGo,2141
|
|
291
291
|
camel/storages/graph_storages/__init__.py,sha256=G29BNn651C0WTOpjCl4QnVM-4B9tcNh8DdmsCiONH8Y,948
|
|
@@ -459,7 +459,7 @@ camel/utils/__init__.py,sha256=qQeMHZJ8Bbgpm4tBu-LWc_P3iFjXBlVfALdKTiD_s8I,3305
|
|
|
459
459
|
camel/utils/async_func.py,sha256=KqoktGSWjZBuAMQ2CV0X6FRgHGlzCKLfeaWvp-f1Qz8,1568
|
|
460
460
|
camel/utils/commons.py,sha256=xEhN__xkM1AT0dvvlAHZiPkGvfpwpj9BhCAWD51qJQ0,37163
|
|
461
461
|
camel/utils/constants.py,sha256=cqnxmpUeOwrtsR-tRO4bbOc6ZP19TLj7avjm3FONMJs,1410
|
|
462
|
-
camel/utils/context_utils.py,sha256=
|
|
462
|
+
camel/utils/context_utils.py,sha256=oJ6mdN2q4NKoHV-KBtlGhCEiKGrOtdwwmZpYbLL-2Ek,15466
|
|
463
463
|
camel/utils/deduplication.py,sha256=UHikAtOW1TTDunf2t_wa2kFbmkrXWf7HfOKwLvwCxzo,8958
|
|
464
464
|
camel/utils/filename.py,sha256=HYNc1wbSCgNR1CN21cwHxdAhpnsf5ySJ6jUDfeqOK20,2532
|
|
465
465
|
camel/utils/langfuse.py,sha256=OowR6A790XG-b0UHiTYduYvS18PvSGFdmqki2Poogo0,8578
|
|
@@ -479,7 +479,7 @@ camel/verifiers/math_verifier.py,sha256=tA1D4S0sm8nsWISevxSN0hvSVtIUpqmJhzqfbuMo
|
|
|
479
479
|
camel/verifiers/models.py,sha256=GdxYPr7UxNrR1577yW4kyroRcLGfd-H1GXgv8potDWU,2471
|
|
480
480
|
camel/verifiers/physics_verifier.py,sha256=c1grrRddcrVN7szkxhv2QirwY9viIRSITWeWFF5HmLs,30187
|
|
481
481
|
camel/verifiers/python_verifier.py,sha256=ogTz77wODfEcDN4tMVtiSkRQyoiZbHPY2fKybn59lHw,20558
|
|
482
|
-
camel_ai-0.2.
|
|
483
|
-
camel_ai-0.2.
|
|
484
|
-
camel_ai-0.2.
|
|
485
|
-
camel_ai-0.2.
|
|
482
|
+
camel_ai-0.2.76a4.dist-info/METADATA,sha256=RpkQkSkR6m7JLdYutzU7R0qy2319g-mAOcWTZgmfgK4,54897
|
|
483
|
+
camel_ai-0.2.76a4.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
|
484
|
+
camel_ai-0.2.76a4.dist-info/licenses/LICENSE,sha256=id0nB2my5kG0xXeimIu5zZrbHLS6EQvxvkKkzIHaT2k,11343
|
|
485
|
+
camel_ai-0.2.76a4.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|