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

Add `GPT_4O_MINI` (#749)

Zecheng Zhang4480cae624e0
diff --git a/camel/agents/chat_agent.py b/camel/agents/chat_agent.py
index 2a41a86b9..5a3e50927 100644
--- a/camel/agents/chat_agent.py
+++ b/camel/agents/chat_agent.py
@@ -127,7 +127,7 @@ class ChatAgent(BaseAgent):
if model is not None
else ModelFactory.create(
model_platform=ModelPlatformType.OPENAI,
- model_type=ModelType.GPT_3_5_TURBO,
+ model_type=ModelType.GPT_4O_MINI,
model_config_dict=ChatGPTConfig().__dict__,
api_key=self._api_key,
)
diff --git a/camel/agents/critic_agent.py b/camel/agents/critic_agent.py
index e83dd856d..0a8de5f63 100644
--- a/camel/agents/critic_agent.py
+++ b/camel/agents/critic_agent.py
@@ -33,7 +33,7 @@ class CriticAgent(ChatAgent):
agent.
model (BaseModelBackend, optional): The model backend to use for
generating responses. (default: :obj:`OpenAIModel` with
- `GPT_3_5_TURBO`)
+ `GPT_4O_MINI`)
message_window_size (int, optional): The maximum number of previous
messages to include in the context window. If `None`, no windowing
is performed. (default: :obj:`6`)
diff --git a/camel/agents/deductive_reasoner_agent.py b/camel/agents/deductive_reasoner_agent.py
index 9b0c09e67..373d9a212 100644
--- a/camel/agents/deductive_reasoner_agent.py
+++ b/camel/agents/deductive_reasoner_agent.py
@@ -35,7 +35,7 @@ class DeductiveReasonerAgent(ChatAgent):
Args:
model (BaseModelBackend, optional): The model backend to use for
generating responses. (default: :obj:`OpenAIModel` with
- `GPT_3_5_TURBO`)
+ `GPT_4O_MINI`)
"""
def __init__(
diff --git a/camel/agents/embodied_agent.py b/camel/agents/embodied_agent.py
index fab361c34..bdb0d6a33 100644
--- a/camel/agents/embodied_agent.py
+++ b/camel/agents/embodied_agent.py
@@ -35,7 +35,7 @@ class EmbodiedAgent(ChatAgent):
system_message (BaseMessage): The system message for the chat agent.
model (BaseModelBackend, optional): The model backend to use for
generating responses. (default: :obj:`OpenAIModel` with
- `GPT_3_5_TURBO`)
+ `GPT_4O_MINI`)
message_window_size (int, optional): The maximum number of previous
messages to include in the context window. If `None`, no windowing
is performed. (default: :obj:`None`)
diff --git a/camel/agents/knowledge_graph_agent.py b/camel/agents/knowledge_graph_agent.py
index 185b43cd7..53dfed377 100644
--- a/camel/agents/knowledge_graph_agent.py
+++ b/camel/agents/knowledge_graph_agent.py
@@ -115,7 +115,7 @@ class KnowledgeGraphAgent(ChatAgent):
Args:
model (BaseModelBackend, optional): The model backend to use for
generating responses. (default: :obj:`OpenAIModel` with
- `GPT_3_5_TURBO`)
+ `GPT_4O_MINI`)
"""
system_message = BaseMessage(
role_name="Graphify",
diff --git a/camel/agents/role_assignment_agent.py b/camel/agents/role_assignment_agent.py
index 50f059826..2e5efd03d 100644
--- a/camel/agents/role_assignment_agent.py
+++ b/camel/agents/role_assignment_agent.py
@@ -27,7 +27,7 @@ class RoleAssignmentAgent(ChatAgent):
Args:
model (BaseModelBackend, optional): The model backend to use for
generating responses. (default: :obj:`OpenAIModel` with
- `GPT_3_5_TURBO`)
+ `GPT_4O_MINI`)
Attributes:
role_assignment_prompt (TextPrompt): A prompt for the agent to generate
diff --git a/camel/agents/search_agent.py b/camel/agents/search_agent.py
index 4e341ad4f..ae53f4da1 100644
--- a/camel/agents/search_agent.py
+++ b/camel/agents/search_agent.py
@@ -26,10 +26,9 @@ class SearchAgent(ChatAgent):
relevance of an answer.
Args:
- model_type (ModelType, optional): The type of model to use for the
- agent. (default: :obj:`ModelType.GPT_3_5_TURBO`)
- model_config (Any, optional): The configuration for the model.
- (default: :obj:`None`)
+ model (BaseModelBackend, optional): The model backend to use for
+ generating responses. (default: :obj:`OpenAIModel` with
+ `GPT_4O_MINI`)
"""
def __init__(
diff --git a/camel/agents/task_agent.py b/camel/agents/task_agent.py
index 1f749ecf2..7d22d8d94 100644
--- a/camel/agents/task_agent.py
+++ b/camel/agents/task_agent.py
@@ -32,7 +32,7 @@ class TaskSpecifyAgent(ChatAgent):
Args:
model (BaseModelBackend, optional): The model backend to use for
generating responses. (default: :obj:`OpenAIModel` with
- `GPT_3_5_TURBO`)
+ `GPT_4O_MINI`)
task_type (TaskType, optional): The type of task for which to generate
a prompt. (default: :obj:`TaskType.AI_SOCIETY`)
task_specify_prompt (Union[str, TextPrompt], optional): The prompt for
@@ -126,7 +126,7 @@ class TaskPlannerAgent(ChatAgent):
Args:
model (BaseModelBackend, optional): The model backend to use for
generating responses. (default: :obj:`OpenAIModel` with
- `GPT_3_5_TURBO`)
+ `GPT_4O_MINI`)
output_language (str, optional): The language to be output by the
agent. (default: :obj:`None`)
"""
@@ -201,7 +201,7 @@ class TaskCreationAgent(ChatAgent):
perform the task.
model (BaseModelBackend, optional): The LLM backend to use for
generating responses. (default: :obj:`OpenAIModel` with
- `GPT_3_5_TURBO`)
+ `GPT_4O_MINI`)
output_language (str, optional): The language to be output by the
agent. (default: :obj:`None`)
message_window_size (int, optional): The maximum number of previous
@@ -312,7 +312,7 @@ class TaskPrioritizationAgent(ChatAgent):
perform the task.
model (BaseModelBackend, optional): The LLM backend to use for
generating responses. (default: :obj:`OpenAIModel` with
- `GPT_3_5_TURBO`)
+ `GPT_4O_MINI`)
output_language (str, optional): The language to be output by the
agent. (default: :obj:`None`)
message_window_size (int, optional): The maximum number of previous
diff --git a/camel/types/enums.py b/camel/types/enums.py
index 8998eab1b..f5bb19d29 100644
--- a/camel/types/enums.py
+++ b/camel/types/enums.py
@@ -29,6 +29,8 @@ class ModelType(Enum):
GPT_4_32K = "gpt-4-32k"
GPT_4_TURBO = "gpt-4-turbo"
GPT_4O = "gpt-4o"
+ GPT_4O_MINI = "gpt-4o-mini"
+
GLM_4 = "glm-4"
GLM_4_OPEN_SOURCE = "glm-4-open-source"
GLM_4V = 'glm-4v'
@@ -44,7 +46,7 @@ class ModelType(Enum):
QWEN_2 = "qwen-2"
# Legacy anthropic models
- # NOTE: anthropic lagecy models only Claude 2.1 has system prompt support
+ # NOTE: anthropic legacy models only Claude 2.1 has system prompt support
CLAUDE_2_1 = "claude-2.1"
CLAUDE_2_0 = "claude-2.0"
CLAUDE_INSTANT_1_2 = "claude-instant-1.2"
@@ -79,6 +81,7 @@ class ModelType(Enum):
ModelType.GPT_4_32K,
ModelType.GPT_4_TURBO,
ModelType.GPT_4O,
+ ModelType.GPT_4O_MINI,
}
@property
@@ -150,6 +153,8 @@ class ModelType(Enum):
return 128000
elif self is ModelType.GPT_4O:
return 128000
+ elif self is ModelType.GPT_4O_MINI:
+ return 128000
elif self == ModelType.GEMINI_1_5_FLASH:
return 1048576
elif self == ModelType.GEMINI_1_5_PRO:
@@ -196,7 +201,7 @@ class ModelType(Enum):
Args:
model_name (str): The name of the model, e.g. "vicuna-7b-v1.5".
Returns:
- bool: Whether the model type mathches the model name.
+ bool: Whether the model type matches the model name.
"""
if self is ModelType.VICUNA:
pattern = r'^vicuna-\d+b-v\d+\.\d+$'
diff --git a/examples/vision/object_recognition.py b/examples/vision/object_recognition.py
index 5c3484171..ce6832ceb 100644
--- a/examples/vision/object_recognition.py
+++ b/examples/vision/object_recognition.py
@@ -16,6 +16,7 @@ import argparse
from PIL import Image
from camel.agents import ChatAgent
+from camel.configs.openai_config import ChatGPTConfig
from camel.generators import PromptTemplateGenerator
from camel.messages import BaseMessage
from camel.models import ModelFactory
@@ -44,7 +45,8 @@ def detect_image_obj(image_path: str) -> None:
)
model = ModelFactory.create(
model_platform=ModelPlatformType.OPENAI,
- model_type=ModelType.GPT_4O,
+ model_type=ModelType.GPT_4O_MINI,
+ model_config_dict=ChatGPTConfig().__dict__,
)
agent = ChatAgent(
assistant_sys_msg,
diff --git a/test/agents/test_chat_agent.py b/test/agents/test_chat_agent.py
index 6c79ed92e..60b64bc3f 100644
--- a/test/agents/test_chat_agent.py
+++ b/test/agents/test_chat_agent.py
@@ -46,7 +46,7 @@ parametrize = pytest.mark.parametrize(
[
ModelFactory.create(
model_platform=ModelPlatformType.OPENAI,
- model_type=ModelType.GPT_3_5_TURBO,
+ model_type=ModelType.GPT_4O_MINI,
model_config_dict=ChatGPTConfig().__dict__,
),
pytest.param(None, marks=pytest.mark.model_backend),
@@ -66,7 +66,7 @@ def test_chat_agent(model):
assistant = ChatAgent(system_msg, model=model)
assert str(assistant) == (
- "ChatAgent(doctor, " f"RoleType.ASSISTANT, {ModelType.GPT_3_5_TURBO})"
+ "ChatAgent(doctor, " f"RoleType.ASSISTANT, {ModelType.GPT_4O_MINI})"
)
assistant.reset()
@@ -178,7 +178,7 @@ def test_chat_agent_multiple_return_messages(n):
model_config = ChatGPTConfig(temperature=1.4, n=n)
model = ModelFactory.create(
model_platform=ModelPlatformType.OPENAI,
- model_type=ModelType.GPT_3_5_TURBO,
+ model_type=ModelType.GPT_4O_MINI,
model_config_dict=model_config.__dict__,
)
system_msg = BaseMessage(
@@ -206,7 +206,7 @@ def test_chat_agent_multiple_return_message_error(n):
model_config = ChatGPTConfig(temperature=1.4, n=n)
model = ModelFactory.create(
model_platform=ModelPlatformType.OPENAI,
- model_type=ModelType.GPT_3_5_TURBO,
+ model_type=ModelType.GPT_4O_MINI,
model_config_dict=model_config.__dict__,
)
system_msg = BaseMessage(
@@ -254,7 +254,7 @@ def test_chat_agent_stream_output():
stream_model_config = ChatGPTConfig(temperature=0, n=2, stream=True)
model = ModelFactory.create(
model_platform=ModelPlatformType.OPENAI,
- model_type=ModelType.GPT_3_5_TURBO,
+ model_type=ModelType.GPT_4O_MINI,
model_config_dict=stream_model_config.__dict__,
)
stream_assistant = ChatAgent(system_msg, model=model)
@@ -362,7 +362,7 @@ def test_function_enabled():
model_config = ChatGPTConfig(tools=[*MATH_FUNCS])
model = ModelFactory.create(
model_platform=ModelPlatformType.OPENAI,
- model_type=ModelType.GPT_3_5_TURBO,
+ model_type=ModelType.GPT_4O_MINI,
model_config_dict=model_config.__dict__,
)
agent_no_func = ChatAgent(system_message=system_message)
@@ -387,7 +387,7 @@ def test_tool_calling_sync():
model_config = ChatGPTConfig(tools=[*MATH_FUNCS])
model = ModelFactory.create(
model_platform=ModelPlatformType.OPENAI,
- model_type=ModelType.GPT_3_5_TURBO,
+ model_type=ModelType.GPT_4O_MINI,
model_config_dict=model_config.__dict__,
)
agent = ChatAgent(
@@ -433,7 +433,7 @@ async def test_tool_calling_math_async():
model_config = ChatGPTConfig(tools=[*math_funcs])
model = ModelFactory.create(
model_platform=ModelPlatformType.OPENAI,
- model_type=ModelType.GPT_3_5_TURBO,
+ model_type=ModelType.GPT_4O_MINI,
model_config_dict=model_config.__dict__,
)
agent = ChatAgent(
@@ -483,7 +483,7 @@ async def test_tool_calling_async():
second (int): Number of seconds to sleep.
Returns:
- integer: Number of seconds sleeped.
+ integer: Number of seconds to sleep.
"""
await asyncio.sleep(second)
return second
@@ -492,7 +492,7 @@ async def test_tool_calling_async():
model = ModelFactory.create(
model_platform=ModelPlatformType.OPENAI,
- model_type=ModelType.GPT_3_5_TURBO,
+ model_type=ModelType.GPT_4O_MINI,
model_config_dict=model_config.__dict__,
)
@@ -560,7 +560,7 @@ def test_chat_agent_vision():
model_config = ChatGPTConfig(temperature=0, max_tokens=200, stop="")
model = ModelFactory.create(
model_platform=ModelPlatformType.OPENAI,
- model_type=ModelType.GPT_4O,
+ model_type=ModelType.GPT_4O_MINI,
model_config_dict=model_config.__dict__,
)
agent = ChatAgent(
diff --git a/test/agents/test_role_playing.py b/test/agents/test_role_playing.py
index aaa7daf07..e126d26d2 100644
--- a/test/agents/test_role_playing.py
+++ b/test/agents/test_role_playing.py
@@ -69,9 +69,9 @@ def test_role_playing_init(model, critic_role_name, with_critic_in_the_loop):
assert isinstance(user_agent, ChatAgent)
if model is None:
assert (
- assistant_agent.model_backend.model_type == ModelType.GPT_3_5_TURBO
+ assistant_agent.model_backend.model_type == ModelType.GPT_4O_MINI
)
- assert user_agent.model_backend.model_type == ModelType.GPT_3_5_TURBO
+ assert user_agent.model_backend.model_type == ModelType.GPT_4O_MINI
else:
assert assistant_agent.model_backend.model_type == ModelType.GPT_4O
assert user_agent.model_backend.model_type == ModelType.GPT_4O
@@ -86,9 +86,7 @@ def test_role_playing_init(model, critic_role_name, with_critic_in_the_loop):
assert isinstance(critic, CriticAgent)
assert role_playing.critic_sys_msg is not None
if model is None:
- assert (
- critic.model_backend.model_type == ModelType.GPT_3_5_TURBO
- )
+ assert critic.model_backend.model_type == ModelType.GPT_4O_MINI
else:
assert critic.model_backend.model_type == ModelType.GPT_4O
@@ -186,9 +184,9 @@ def test_role_playing_role_sequence(model=None):
user_role_sequence = []
input_msg = role_playing.init_chat()
- assistant_response, user_response = role_playing.step(input_msg)
+ assistant_response, _ = role_playing.step(input_msg)
input_msg = assistant_response.msg
- assistant_response, user_response = role_playing.step(input_msg)
+ assistant_response, _ = role_playing.step(input_msg)
for record in role_playing.user_agent.memory.get_context()[0]:
user_role_sequence.append(record["role"])
diff --git a/test/models/test_openai_model.py b/test/models/test_openai_model.py
index 7cb294f2d..d84c70145 100644
--- a/test/models/test_openai_model.py
+++ b/test/models/test_openai_model.py
@@ -30,6 +30,7 @@ from camel.utils import OpenAITokenCounter
ModelType.GPT_4_32K,
ModelType.GPT_4_TURBO,
ModelType.GPT_4O,
+ ModelType.GPT_4O_MINI,
],
)
def test_openai_model(model_type):