camel-ai 0.2.69a7__py3-none-any.whl → 0.2.71a1__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/role_playing.py +26 -28
- camel/societies/workforce/role_playing_worker.py +4 -4
- camel/societies/workforce/single_agent_worker.py +4 -4
- camel/societies/workforce/workforce.py +462 -159
- camel/societies/workforce/workforce_logger.py +37 -24
- camel/storages/__init__.py +2 -0
- camel/storages/vectordb_storages/__init__.py +2 -0
- camel/storages/vectordb_storages/pgvector.py +349 -0
- camel/tasks/task.py +83 -7
- camel/toolkits/file_write_toolkit.py +21 -7
- camel/toolkits/human_toolkit.py +23 -8
- camel/toolkits/non_visual_browser_toolkit/browser_non_visual_toolkit.py +23 -2
- camel/toolkits/non_visual_browser_toolkit/nv_browser_session.py +53 -11
- camel/toolkits/non_visual_browser_toolkit/snapshot.js +211 -131
- camel/toolkits/non_visual_browser_toolkit/snapshot.py +9 -8
- camel/toolkits/terminal_toolkit.py +28 -20
- camel/toolkits/video_download_toolkit.py +5 -1
- camel/types/enums.py +3 -0
- {camel_ai-0.2.69a7.dist-info → camel_ai-0.2.71a1.dist-info}/METADATA +5 -1
- {camel_ai-0.2.69a7.dist-info → camel_ai-0.2.71a1.dist-info}/RECORD +23 -22
- {camel_ai-0.2.69a7.dist-info → camel_ai-0.2.71a1.dist-info}/WHEEL +0 -0
- {camel_ai-0.2.69a7.dist-info → camel_ai-0.2.71a1.dist-info}/licenses/LICENSE +0 -0
camel/__init__.py
CHANGED
camel/societies/role_playing.py
CHANGED
|
@@ -556,13 +556,12 @@ class RolePlaying:
|
|
|
556
556
|
)
|
|
557
557
|
user_msg = self._reduce_message_options(user_response.msgs)
|
|
558
558
|
|
|
559
|
-
# To prevent recording
|
|
560
|
-
#
|
|
561
|
-
#
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
):
|
|
559
|
+
# To prevent recording missing messages: ChatAgent.step automatically
|
|
560
|
+
# saves the response to memory only when a single message is returned.
|
|
561
|
+
# When multi-response support is enabled (n > 1), it is the caller's
|
|
562
|
+
# responsibility to record the selected message. Therefore, we record
|
|
563
|
+
# it here after choosing one message via `_reduce_message_options()`.
|
|
564
|
+
if self._is_multi_response(self.user_agent):
|
|
566
565
|
self.user_agent.record_message(user_msg)
|
|
567
566
|
|
|
568
567
|
assistant_response = self.assistant_agent.step(user_msg)
|
|
@@ -579,13 +578,7 @@ class RolePlaying:
|
|
|
579
578
|
)
|
|
580
579
|
assistant_msg = self._reduce_message_options(assistant_response.msgs)
|
|
581
580
|
|
|
582
|
-
|
|
583
|
-
# step and once in role play), and the model generates only one
|
|
584
|
-
# response when multi-response support is enabled.
|
|
585
|
-
if (
|
|
586
|
-
'n' in self.assistant_agent.model_backend.model_config_dict.keys()
|
|
587
|
-
and self.assistant_agent.model_backend.model_config_dict['n'] > 1
|
|
588
|
-
):
|
|
581
|
+
if self._is_multi_response(self.assistant_agent):
|
|
589
582
|
self.assistant_agent.record_message(assistant_msg)
|
|
590
583
|
|
|
591
584
|
return (
|
|
@@ -639,13 +632,7 @@ class RolePlaying:
|
|
|
639
632
|
)
|
|
640
633
|
user_msg = self._reduce_message_options(user_response.msgs)
|
|
641
634
|
|
|
642
|
-
|
|
643
|
-
# step and once in role play), and the model generates only one
|
|
644
|
-
# response when multi-response support is enabled.
|
|
645
|
-
if (
|
|
646
|
-
'n' in self.user_agent.model_backend.model_config_dict.keys()
|
|
647
|
-
and self.user_agent.model_backend.model_config_dict['n'] > 1
|
|
648
|
-
):
|
|
635
|
+
if self._is_multi_response(self.user_agent):
|
|
649
636
|
self.user_agent.record_message(user_msg)
|
|
650
637
|
|
|
651
638
|
assistant_response = await self.assistant_agent.astep(user_msg)
|
|
@@ -662,13 +649,7 @@ class RolePlaying:
|
|
|
662
649
|
)
|
|
663
650
|
assistant_msg = self._reduce_message_options(assistant_response.msgs)
|
|
664
651
|
|
|
665
|
-
|
|
666
|
-
# step and once in role play), and the model generates only one
|
|
667
|
-
# response when multi-response support is enabled.
|
|
668
|
-
if (
|
|
669
|
-
'n' in self.assistant_agent.model_backend.model_config_dict.keys()
|
|
670
|
-
and self.assistant_agent.model_backend.model_config_dict['n'] > 1
|
|
671
|
-
):
|
|
652
|
+
if self._is_multi_response(self.assistant_agent):
|
|
672
653
|
self.assistant_agent.record_message(assistant_msg)
|
|
673
654
|
|
|
674
655
|
return (
|
|
@@ -730,3 +711,20 @@ class RolePlaying:
|
|
|
730
711
|
new_instance.critic = self.critic.clone(with_memory)
|
|
731
712
|
|
|
732
713
|
return new_instance
|
|
714
|
+
|
|
715
|
+
def _is_multi_response(self, agent: ChatAgent) -> bool:
|
|
716
|
+
r"""Checks if the given agent supports multi-response.
|
|
717
|
+
|
|
718
|
+
Args:
|
|
719
|
+
agent (ChatAgent): The agent to check for multi-response support.
|
|
720
|
+
|
|
721
|
+
Returns:
|
|
722
|
+
bool: True if the agent supports multi-response, False otherwise.
|
|
723
|
+
"""
|
|
724
|
+
if (
|
|
725
|
+
'n' in agent.model_backend.model_config_dict.keys()
|
|
726
|
+
and agent.model_backend.model_config_dict['n'] is not None
|
|
727
|
+
and agent.model_backend.model_config_dict['n'] > 1
|
|
728
|
+
):
|
|
729
|
+
return True
|
|
730
|
+
return False
|
|
@@ -27,7 +27,7 @@ from camel.societies.workforce.prompts import (
|
|
|
27
27
|
)
|
|
28
28
|
from camel.societies.workforce.utils import TaskResult
|
|
29
29
|
from camel.societies.workforce.worker import Worker
|
|
30
|
-
from camel.tasks.task import Task, TaskState,
|
|
30
|
+
from camel.tasks.task import Task, TaskState, is_task_result_insufficient
|
|
31
31
|
|
|
32
32
|
|
|
33
33
|
class RolePlayingWorker(Worker):
|
|
@@ -178,14 +178,14 @@ class RolePlayingWorker(Worker):
|
|
|
178
178
|
result_dict = json.loads(response.msg.content)
|
|
179
179
|
task_result = TaskResult(**result_dict)
|
|
180
180
|
|
|
181
|
-
|
|
181
|
+
task.result = task_result.content
|
|
182
|
+
|
|
183
|
+
if is_task_result_insufficient(task):
|
|
182
184
|
print(
|
|
183
185
|
f"{Fore.RED}Task {task.id}: Content validation failed - "
|
|
184
186
|
f"task marked as failed{Fore.RESET}"
|
|
185
187
|
)
|
|
186
188
|
return TaskState.FAILED
|
|
187
189
|
|
|
188
|
-
task.result = task_result.content
|
|
189
|
-
|
|
190
190
|
print(f"Task result: {task.result}\n")
|
|
191
191
|
return TaskState.DONE
|
|
@@ -26,7 +26,7 @@ from camel.agents import ChatAgent
|
|
|
26
26
|
from camel.societies.workforce.prompts import PROCESS_TASK_PROMPT
|
|
27
27
|
from camel.societies.workforce.utils import TaskResult
|
|
28
28
|
from camel.societies.workforce.worker import Worker
|
|
29
|
-
from camel.tasks.task import Task, TaskState,
|
|
29
|
+
from camel.tasks.task import Task, TaskState, is_task_result_insufficient
|
|
30
30
|
|
|
31
31
|
|
|
32
32
|
class AgentPool:
|
|
@@ -352,14 +352,14 @@ class SingleAgentWorker(Worker):
|
|
|
352
352
|
if task_result.failed:
|
|
353
353
|
return TaskState.FAILED
|
|
354
354
|
|
|
355
|
-
|
|
355
|
+
task.result = task_result.content
|
|
356
|
+
|
|
357
|
+
if is_task_result_insufficient(task):
|
|
356
358
|
print(
|
|
357
359
|
f"{Fore.RED}Task {task.id}: Content validation failed - "
|
|
358
360
|
f"task marked as failed{Fore.RESET}"
|
|
359
361
|
)
|
|
360
362
|
return TaskState.FAILED
|
|
361
|
-
|
|
362
|
-
task.result = task_result.content
|
|
363
363
|
return TaskState.DONE
|
|
364
364
|
|
|
365
365
|
async def _listen_to_channel(self):
|