Skip to content

armgit / camel

Public Imported from GitHub
0

🐫 CAMEL: The first and the best multi-agent framework. Finding the Scaling Law of Agents. https://www.camel-ai.org

chore: add default model for workforce (#3625)

Tao Sun5abf4254782f
diff --git a/camel/societies/workforce/workforce.py b/camel/societies/workforce/workforce.py
index 2bd96d9b0..1785eb7f3 100644
--- a/camel/societies/workforce/workforce.py
+++ b/camel/societies/workforce/workforce.py
@@ -48,7 +48,7 @@ if TYPE_CHECKING:
from camel.agents import ChatAgent
from camel.logger import get_logger
from camel.messages.base import BaseMessage
-from camel.models import ModelFactory
+from camel.models import BaseModelBackend, ModelManager
from camel.societies.workforce.base import BaseNode
from camel.societies.workforce.prompts import (
ASSIGN_TASK_PROMPT,
@@ -91,7 +91,6 @@ from camel.toolkits import (
SearchToolkit,
ThinkingToolkit,
)
-from camel.types import ModelPlatformType, ModelType
from camel.utils import dependencies_required
from .events import (
@@ -201,6 +200,11 @@ class Workforce(BaseNode):
handle failed tasks. If None, workers will be created with default
settings including SearchToolkit, CodeExecutionToolkit, and
ThinkingToolkit. (default: :obj:`None`)
+ default_model (Optional[Union[BaseModelBackend, ModelManager]],
+ optional): Model backend or manager to use when creating default
+ coordinator, task, or dynamic worker agents. If None, agents
+ will be created using ModelPlatformType.DEFAULT and
+ ModelType.DEFAULT settings. (default: :obj:`None`)
graceful_shutdown_timeout (float, optional): The timeout in seconds
for graceful shutdown when a task fails 3 times. During this
period, the workforce remains active for debugging.
@@ -311,6 +315,7 @@ class Workforce(BaseNode):
coordinator_agent: Optional[ChatAgent] = None,
task_agent: Optional[ChatAgent] = None,
new_worker_agent: Optional[ChatAgent] = None,
+ default_model: Optional[Union[BaseModelBackend, ModelManager]] = None,
graceful_shutdown_timeout: float = 15.0,
share_memory: bool = False,
use_structured_output_handler: bool = True,
@@ -327,6 +332,7 @@ class Workforce(BaseNode):
] = deque()
self._children = children or []
self.new_worker_agent = new_worker_agent
+ self.default_model = default_model
self.graceful_shutdown_timeout = graceful_shutdown_timeout
self.share_memory = share_memory
self.use_structured_output_handler = use_structured_output_handler
@@ -391,7 +397,10 @@ class Workforce(BaseNode):
"ChatAgent settings (ModelPlatformType.DEFAULT, "
"ModelType.DEFAULT) with default system message."
)
- self.coordinator_agent = ChatAgent(coord_agent_sys_msg)
+ self.coordinator_agent = ChatAgent(
+ coord_agent_sys_msg,
+ model=self.default_model,
+ )
else:
logger.info(
"Custom coordinator_agent provided. Preserving user's "
@@ -450,6 +459,7 @@ class Workforce(BaseNode):
)
self.task_agent = ChatAgent(
task_sys_msg,
+ model=self.default_model,
)
else:
logger.info(
@@ -4058,15 +4068,9 @@ class Workforce(BaseNode):
*ThinkingToolkit().get_tools(),
]
- model = ModelFactory.create(
- model_platform=ModelPlatformType.DEFAULT,
- model_type=ModelType.DEFAULT,
- model_config_dict={"temperature": 0},
- )
-
return ChatAgent(
system_message=worker_sys_msg,
- model=model,
+ model=self.default_model,
tools=function_list, # type: ignore[arg-type]
pause_event=self._pause_event,
)
@@ -5496,6 +5500,7 @@ class Workforce(BaseNode):
new_worker_agent=self.new_worker_agent.clone(with_memory)
if self.new_worker_agent
else None,
+ default_model=self.default_model,
graceful_shutdown_timeout=self.graceful_shutdown_timeout,
share_memory=self.share_memory,
use_structured_output_handler=self.use_structured_output_handler,