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

fix: role playing with specific model (#736)

Appointat49a08f235838
diff --git a/examples/models/role_playing_with_claude.py b/examples/models/role_playing_with_claude.py
index c53e8b8e8..c0c0ac372 100644
--- a/examples/models/role_playing_with_claude.py
+++ b/examples/models/role_playing_with_claude.py
@@ -23,13 +23,17 @@ from camel.utils import print_text_animated
def main(model_type=None) -> None:
task_prompt = "Develop a trading bot for the stock market"
+ model = ModelFactory.create(
+ model_platform=ModelPlatformType.ANTHROPIC,
+ model_type=model_type,
+ model_config_dict=AnthropicConfig().__dict__,
+ )
+
+ # Update agent_kwargs to use the created models
agent_kwargs = {
- role: ModelFactory.create(
- model_platform=ModelPlatformType.ANTHROPIC,
- model_type=model_type,
- model_config_dict=AnthropicConfig().__dict__,
- )
- for role in ["assistant", "user", "task-specify"]
+ "assistant": {"model": model},
+ "user": {"model": model},
+ "task-specify": {"model": model},
}
role_play_session = RolePlaying(
diff --git a/examples/models/role_playing_with_gemini.py b/examples/models/role_playing_with_gemini.py
index fdb4e8cda..182f897f1 100644
--- a/examples/models/role_playing_with_gemini.py
+++ b/examples/models/role_playing_with_gemini.py
@@ -24,23 +24,27 @@ from camel.utils import print_text_animated
def main(model_type=None) -> None:
task_prompt = "Develop a trading bot for the stock market"
+ model = ModelFactory.create(
+ model_platform=ModelPlatformType.GEMINI,
+ model_type=model_type,
+ model_config_dict=GeminiConfig().__dict__,
+ )
+
+ # Update agent_kwargs to use the created models
agent_kwargs = {
- role: ModelFactory.create(
- model_platform=ModelPlatformType.GEMINI,
- model_type=model_type,
- model_config_dict=GeminiConfig().__dict__,
- )
- for role in ["assistant", "user", "task-specify"]
+ "assistant": {"model": model},
+ "user": {"model": model},
+ "task-specify": {"model": model},
}
role_play_session = RolePlaying(
assistant_role_name="Python Programmer",
- assistant_agent_kwargs={'model': agent_kwargs["assistant"]},
+ assistant_agent_kwargs=agent_kwargs["assistant"],
user_role_name="Stock Trader",
- user_agent_kwargs={'model': agent_kwargs["assistant"]},
+ user_agent_kwargs=agent_kwargs["user"],
task_prompt=task_prompt,
with_task_specify=True,
- task_specify_agent_kwargs={'model': agent_kwargs["task-specify"]},
+ task_specify_agent_kwargs=agent_kwargs["task-specify"],
)
print(
diff --git a/examples/models/role_playing_with_open_source_model.py b/examples/models/role_playing_with_open_source_model.py
index 71711a50d..a17d91170 100644
--- a/examples/models/role_playing_with_open_source_model.py
+++ b/examples/models/role_playing_with_open_source_model.py
@@ -33,19 +33,21 @@ def main(
) -> None:
task_prompt = "Develop a trading bot for the stock market"
+ model = ModelFactory.create(
+ model_platform=model_platform,
+ model_type=model_type,
+ model_config_dict=OpenSourceConfig(
+ model_path=model_path,
+ server_url=server_url,
+ api_params=ChatGPTConfig(temperature=0),
+ ).__dict__,
+ )
+
+ # Update agent_kwargs to use the created models
agent_kwargs = {
- role: dict(
- model=ModelFactory.create(
- model_platform=model_platform,
- model_type=model_type,
- model_config_dict=OpenSourceConfig(
- model_path=model_path,
- server_url=server_url,
- api_params=ChatGPTConfig(temperature=0),
- ).__dict__,
- ),
- )
- for role in ["assistant", "user", "task-specify"]
+ "assistant": {"model": model},
+ "user": {"model": model},
+ "task-specify": {"model": model},
}
role_play_session = RolePlaying(