camel-ai 0.2.76a14__py3-none-any.whl → 0.2.78__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 +278 -154
- camel/data_collectors/alpaca_collector.py +15 -6
- camel/societies/workforce/prompts.py +131 -50
- camel/societies/workforce/single_agent_worker.py +390 -11
- camel/societies/workforce/structured_output_handler.py +30 -18
- camel/societies/workforce/utils.py +105 -12
- camel/societies/workforce/workforce.py +818 -224
- camel/societies/workforce/workforce_logger.py +24 -5
- camel/toolkits/context_summarizer_toolkit.py +2 -2
- camel/toolkits/excel_toolkit.py +1 -1
- camel/toolkits/file_toolkit.py +3 -2
- camel/toolkits/terminal_toolkit/utils.py +106 -154
- camel/types/enums.py +4 -4
- camel/utils/context_utils.py +379 -22
- {camel_ai-0.2.76a14.dist-info → camel_ai-0.2.78.dist-info}/METADATA +10 -1
- {camel_ai-0.2.76a14.dist-info → camel_ai-0.2.78.dist-info}/RECORD +19 -19
- {camel_ai-0.2.76a14.dist-info → camel_ai-0.2.78.dist-info}/WHEEL +0 -0
- {camel_ai-0.2.76a14.dist-info → camel_ai-0.2.78.dist-info}/licenses/LICENSE +0 -0
|
@@ -70,16 +70,25 @@ class AlpacaDataCollector(BaseDataCollector):
|
|
|
70
70
|
if not history:
|
|
71
71
|
raise ValueError("No data collected.")
|
|
72
72
|
|
|
73
|
-
#
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
73
|
+
# Filter out system and tool-related messages
|
|
74
|
+
# Keep only user and final assistant messages
|
|
75
|
+
filtered_history = []
|
|
76
|
+
for msg in history:
|
|
77
|
+
if msg.role == "user":
|
|
78
|
+
filtered_history.append(msg)
|
|
79
|
+
elif msg.role == "assistant" and msg.message:
|
|
80
|
+
# Keep assistant messages with actual content
|
|
81
|
+
# (skip empty ones that only contain tool calls)
|
|
82
|
+
filtered_history.append(msg)
|
|
83
|
+
|
|
84
|
+
# Validate filtered history
|
|
85
|
+
if len(filtered_history) != 2:
|
|
77
86
|
raise ValueError(
|
|
78
87
|
f"AlpacaDataCollector only supports one message pair, but "
|
|
79
|
-
f"got {len(
|
|
88
|
+
f"got {len(filtered_history)} after filtering tool messages"
|
|
80
89
|
)
|
|
81
90
|
|
|
82
|
-
input_message, output_message =
|
|
91
|
+
input_message, output_message = filtered_history
|
|
83
92
|
instruction = (
|
|
84
93
|
self.system_message.content if self.system_message else ""
|
|
85
94
|
) + str(input_message.message)
|
|
@@ -293,58 +293,139 @@ Each subtask should be:
|
|
|
293
293
|
- Written without any relative references (e.g., "the previous task").
|
|
294
294
|
"""
|
|
295
295
|
|
|
296
|
-
|
|
297
|
-
"""You
|
|
298
|
-
|
|
299
|
-
**TASK
|
|
300
|
-
Task ID: {task_id}
|
|
301
|
-
Task Content: {task_content}
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
-
|
|
330
|
-
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
296
|
+
TASK_ANALYSIS_PROMPT = TextPrompt(
|
|
297
|
+
"""You are analyzing a task to evaluate its quality and determine recovery actions if needed.
|
|
298
|
+
|
|
299
|
+
**TASK INFORMATION:**
|
|
300
|
+
- Task ID: {task_id}
|
|
301
|
+
- Task Content: {task_content}
|
|
302
|
+
- Task Result: {task_result}
|
|
303
|
+
- Failure Count: {failure_count}
|
|
304
|
+
- Task Depth: {task_depth}
|
|
305
|
+
- Assigned Worker: {assigned_worker}
|
|
306
|
+
|
|
307
|
+
**ISSUE TYPE: {issue_type}**
|
|
308
|
+
|
|
309
|
+
{issue_specific_analysis}
|
|
310
|
+
|
|
311
|
+
**STEP 1: EVALUATE TASK QUALITY**
|
|
312
|
+
|
|
313
|
+
First, assess whether the task was completed successfully and meets quality standards:
|
|
314
|
+
|
|
315
|
+
**For Task Failures (with error messages):**
|
|
316
|
+
- The task did not complete successfully
|
|
317
|
+
- An error occurred during execution
|
|
318
|
+
- Quality is automatically insufficient
|
|
319
|
+
- Focus on analyzing the error cause
|
|
320
|
+
|
|
321
|
+
**For Quality Issues (task completed but needs evaluation):**
|
|
322
|
+
Evaluate the task result based on these criteria:
|
|
323
|
+
1. **Completeness**: Does the result fully address all task requirements?
|
|
324
|
+
2. **Accuracy**: Is the result correct and well-structured?
|
|
325
|
+
3. **Missing Elements**: Are there any missing components or quality issues?
|
|
326
|
+
|
|
327
|
+
Provide:
|
|
328
|
+
- Quality score (0-100): Objective assessment of result quality
|
|
329
|
+
- Specific issues list: Any problems found in the result
|
|
330
|
+
- Quality sufficient: Boolean indicating if quality meets standards
|
|
331
|
+
|
|
332
|
+
**STEP 2: DETERMINE RECOVERY STRATEGY (if quality insufficient)**
|
|
333
|
+
|
|
334
|
+
If the task quality is insufficient, select the best recovery strategy:
|
|
335
|
+
|
|
336
|
+
**Available Strategies:**
|
|
337
|
+
|
|
338
|
+
1. **retry** - Retry with the same worker and task content
|
|
339
|
+
- **Best for**:
|
|
340
|
+
* Network errors, connection timeouts, temporary API issues
|
|
341
|
+
* Random failures that are likely temporary
|
|
342
|
+
* Minor quality issues that may resolve on retry
|
|
343
|
+
- **Not suitable for**:
|
|
344
|
+
* Fundamental task misunderstandings
|
|
345
|
+
* Worker capability gaps
|
|
346
|
+
* Persistent quality problems
|
|
347
|
+
|
|
348
|
+
2. **reassign** - Assign to a different worker
|
|
349
|
+
- **Best for**:
|
|
350
|
+
* Current worker lacks required skills/expertise
|
|
351
|
+
* Worker-specific quality issues
|
|
352
|
+
* Task requires different specialization
|
|
353
|
+
- **Not suitable for**:
|
|
354
|
+
* Task description is unclear (use replan instead)
|
|
355
|
+
* Task is too complex (use decompose instead)
|
|
356
|
+
- **Note**: Only available for quality issues, not failures
|
|
357
|
+
|
|
358
|
+
3. **replan** - Modify task content with clearer instructions
|
|
359
|
+
- **Best for**:
|
|
360
|
+
* Unclear or ambiguous requirements
|
|
361
|
+
* Missing context or information
|
|
362
|
+
* Task description needs improvement
|
|
363
|
+
- **Requirements**:
|
|
364
|
+
* Provide modified_task_content with enhanced, clear instructions
|
|
365
|
+
* Modified task must be actionable for an AI agent
|
|
366
|
+
* Address the root cause identified in issues
|
|
367
|
+
|
|
368
|
+
4. **decompose** - Break into smaller, manageable subtasks
|
|
369
|
+
- **Best for**:
|
|
370
|
+
* Task is too complex for a single worker
|
|
371
|
+
* Multiple distinct sub-problems exist
|
|
372
|
+
* Persistent failures despite retries
|
|
373
|
+
* Capability mismatches that need specialization
|
|
374
|
+
- **Consider**:
|
|
375
|
+
* Task depth (avoid if depth > 2)
|
|
376
|
+
* Whether subtasks can run in parallel
|
|
377
|
+
|
|
378
|
+
5. **create_worker** - Create new specialized worker
|
|
379
|
+
- **Best for**:
|
|
380
|
+
* No existing worker has required capabilities
|
|
381
|
+
* Need specialized skills not currently available
|
|
382
|
+
- **Consider**:
|
|
383
|
+
* Whether decomposition could work instead
|
|
384
|
+
* Cost of creating new worker vs alternatives
|
|
385
|
+
- **Note**: Only available for task failures, not quality issues
|
|
386
|
+
|
|
387
|
+
**DECISION GUIDELINES:**
|
|
388
|
+
|
|
389
|
+
**Priority Rules:**
|
|
390
|
+
1. Connection/Network Errors → **retry** (almost always)
|
|
391
|
+
2. Deep Tasks (depth > 2) → Avoid decompose, prefer **retry** or **replan**
|
|
392
|
+
3. Worker Skill Mismatch → **reassign** (quality) or **decompose** (failure)
|
|
393
|
+
4. Unclear Requirements → **replan** with specifics
|
|
394
|
+
5. Task Too Complex → **decompose** into subtasks
|
|
338
395
|
|
|
339
396
|
**RESPONSE FORMAT:**
|
|
340
|
-
|
|
341
|
-
- "strategy": one of "retry", "replan", or "decompose"
|
|
342
|
-
- "reasoning": explanation for your choice (1-2 sentences)
|
|
343
|
-
- "modified_task_content": new task content if strategy is "replan", null otherwise
|
|
397
|
+
{response_format}
|
|
344
398
|
|
|
345
|
-
**
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
399
|
+
**CRITICAL**:
|
|
400
|
+
- Return ONLY a valid JSON object
|
|
401
|
+
- No explanations or text outside the JSON structure
|
|
402
|
+
- Ensure all required fields are included
|
|
403
|
+
- Use null for optional fields when not applicable
|
|
349
404
|
"""
|
|
350
405
|
)
|
|
406
|
+
|
|
407
|
+
FAILURE_ANALYSIS_RESPONSE_FORMAT = """JSON format:
|
|
408
|
+
{
|
|
409
|
+
"reasoning": "explanation (1-2 sentences)",
|
|
410
|
+
"recovery_strategy": "retry|replan|decompose|create_worker",
|
|
411
|
+
"modified_task_content": "new content if replan, else null",
|
|
412
|
+
"issues": ["error1", "error2"]
|
|
413
|
+
}"""
|
|
414
|
+
|
|
415
|
+
QUALITY_EVALUATION_RESPONSE_FORMAT = """JSON format:
|
|
416
|
+
{
|
|
417
|
+
"quality_score": 0-100,
|
|
418
|
+
"reasoning": "explanation (1-2 sentences)",
|
|
419
|
+
"issues": ["issue1", "issue2"],
|
|
420
|
+
"recovery_strategy": "retry|reassign|replan|decompose or null",
|
|
421
|
+
"modified_task_content": "new content if replan, else null"
|
|
422
|
+
}"""
|
|
423
|
+
|
|
424
|
+
TASK_AGENT_SYSTEM_MESSAGE = """You are an intelligent task management assistant responsible for planning, analyzing, and quality control.
|
|
425
|
+
|
|
426
|
+
Your responsibilities include:
|
|
427
|
+
1. **Task Decomposition**: Breaking down complex tasks into manageable subtasks that can be executed efficiently and in parallel when possible.
|
|
428
|
+
2. **Failure Analysis**: Analyzing task failures to determine the root cause and recommend appropriate recovery strategies (retry, replan, decompose, or create new worker).
|
|
429
|
+
3. **Quality Evaluation**: Assessing completed task results to ensure they meet quality standards and recommending recovery strategies if quality is insufficient (retry, reassign, replan, or decompose).
|
|
430
|
+
|
|
431
|
+
You must provide structured, actionable analysis based on the task context, failure history, worker capabilities, and quality criteria. Your decisions directly impact the efficiency and success of the workforce system."""
|