From ce8936fcd6194ccd961c3e5b59a7f99785ecc1c4 Mon Sep 17 00:00:00 2001 From: Wendong-Fan <133094783+Wendong-Fan@users.noreply.github.com> Date: Sat, 1 Feb 2025 05:21:55 +0800 Subject: [PATCH] feat: Support OpenAI o3 mini (#1533) --- .github/ISSUE_TEMPLATE/bug_report.yml | 2 +- camel/__init__.py | 2 +- camel/models/openai_model.py | 1 + camel/types/enums.py | 3 + camel/utils/token_counting.py | 2 +- docs/conf.py | 2 +- docs/get_started/installation.md | 2 +- docs/key_modules/loaders.md | 4 +- examples/models/openai_o1_example.py | 2 +- examples/models/openai_o3_mini_example.py | 92 +++++++++++++++++++++++ pyproject.toml | 2 +- 11 files changed, 105 insertions(+), 9 deletions(-) create mode 100644 examples/models/openai_o3_mini_example.py diff --git a/.github/ISSUE_TEMPLATE/bug_report.yml b/.github/ISSUE_TEMPLATE/bug_report.yml index 438003c8d7..9c7eb26200 100644 --- a/.github/ISSUE_TEMPLATE/bug_report.yml +++ b/.github/ISSUE_TEMPLATE/bug_report.yml @@ -26,7 +26,7 @@ body: attributes: label: What version of camel are you using? description: Run command `python3 -c 'print(__import__("camel").__version__)'` in your shell and paste the output here. - placeholder: E.g., 0.2.18 + placeholder: E.g., 0.2.19 validations: required: true diff --git a/camel/__init__.py b/camel/__init__.py index 6156f30e8f..7c368a7eef 100644 --- a/camel/__init__.py +++ b/camel/__init__.py @@ -14,7 +14,7 @@ from camel.logger import disable_logging, enable_logging, set_log_level -__version__ = '0.2.18' +__version__ = '0.2.19' __all__ = [ '__version__', diff --git a/camel/models/openai_model.py b/camel/models/openai_model.py index d524402556..0d905ef8a8 100644 --- a/camel/models/openai_model.py +++ b/camel/models/openai_model.py @@ -111,6 +111,7 @@ def run( ModelType.O1, ModelType.O1_MINI, ModelType.O1_PREVIEW, + ModelType.O3_MINI, ]: warnings.warn( "Warning: You are using an O1 model (O1_MINI or O1_PREVIEW), " diff --git a/camel/types/enums.py b/camel/types/enums.py index 1ed59ca880..5fbc1acb55 100644 --- a/camel/types/enums.py +++ b/camel/types/enums.py @@ -37,6 +37,7 @@ class ModelType(UnifiedModelType, Enum): O1 = "o1" O1_PREVIEW = "o1-preview" O1_MINI = "o1-mini" + O3_MINI = "o3-mini" GLM_4 = "glm-4" GLM_4V = 'glm-4v' @@ -215,6 +216,7 @@ def is_openai(self) -> bool: ModelType.O1, ModelType.O1_PREVIEW, ModelType.O1_MINI, + ModelType.O3_MINI, } @property @@ -562,6 +564,7 @@ def token_limit(self) -> int: return 131_072 elif self in { ModelType.O1, + ModelType.O3_MINI, ModelType.CLAUDE_2_1, ModelType.CLAUDE_3_OPUS, ModelType.CLAUDE_3_SONNET, diff --git a/camel/utils/token_counting.py b/camel/utils/token_counting.py index 28399fe3f1..d483996c18 100644 --- a/camel/utils/token_counting.py +++ b/camel/utils/token_counting.py @@ -112,7 +112,7 @@ def __init__(self, model: UnifiedModelType): elif ("gpt-3.5-turbo" in self.model) or ("gpt-4" in self.model): self.tokens_per_message = 3 self.tokens_per_name = 1 - elif "o1" in self.model: + elif ("o1" in self.model) or ("o3" in self.model): self.tokens_per_message = 2 self.tokens_per_name = 1 else: diff --git a/docs/conf.py b/docs/conf.py index 378389b64d..2232de93e9 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -27,7 +27,7 @@ project = 'CAMEL' copyright = '2024, CAMEL-AI.org' author = 'CAMEL-AI.org' -release = '0.2.18' +release = '0.2.19' html_favicon = ( 'https://raw.githubusercontent.com/camel-ai/camel/master/misc/favicon.png' diff --git a/docs/get_started/installation.md b/docs/get_started/installation.md index 9ff30dfb26..3ffc54132c 100644 --- a/docs/get_started/installation.md +++ b/docs/get_started/installation.md @@ -60,7 +60,7 @@ conda create --name camel python=3.10 conda activate camel # Clone github repo -git clone -b v0.2.18 https://github.com/camel-ai/camel.git +git clone -b v0.2.19 https://github.com/camel-ai/camel.git # Change directory into project directory cd camel diff --git a/docs/key_modules/loaders.md b/docs/key_modules/loaders.md index 7b35b49402..2d4f1881d7 100644 --- a/docs/key_modules/loaders.md +++ b/docs/key_modules/loaders.md @@ -340,14 +340,14 @@ response = jina_reader.read_content("https://docs.camel-ai.org/") print(response) ``` ```markdown ->>>Welcome to CAMEL’s documentation! — CAMEL 0.2.18 documentation +>>>Welcome to CAMEL’s documentation! — CAMEL 0.2.19 documentation =============== [Skip to main content](https://docs.camel-ai.org/#main-content) Back to top Ctrl+K - [![Image 1](https://raw.githubusercontent.com/camel-ai/camel/master/misc/logo_light.png) ![Image 2](https://raw.githubusercontent.com/camel-ai/camel/master/misc/logo_light.png)CAMEL 0.2.18](https://docs.camel-ai.org/#) + [![Image 1](https://raw.githubusercontent.com/camel-ai/camel/master/misc/logo_light.png) ![Image 2](https://raw.githubusercontent.com/camel-ai/camel/master/misc/logo_light.png)CAMEL 0.2.19](https://docs.camel-ai.org/#) Search Ctrl+K diff --git a/examples/models/openai_o1_example.py b/examples/models/openai_o1_example.py index f0764545d0..682a6b7f30 100644 --- a/examples/models/openai_o1_example.py +++ b/examples/models/openai_o1_example.py @@ -20,7 +20,7 @@ o1_model = ModelFactory.create( model_platform=ModelPlatformType.OPENAI, model_type=ModelType.O1_MINI, # Or ModelType.O1 - model_config_dict=ChatGPTConfig(temperature=0.0).as_dict(), + model_config_dict=ChatGPTConfig().as_dict(), ) # Set agent diff --git a/examples/models/openai_o3_mini_example.py b/examples/models/openai_o3_mini_example.py new file mode 100644 index 0000000000..d2d89f77ee --- /dev/null +++ b/examples/models/openai_o3_mini_example.py @@ -0,0 +1,92 @@ +# ========= Copyright 2023-2024 @ CAMEL-AI.org. All Rights Reserved. ========= +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# ========= Copyright 2023-2024 @ CAMEL-AI.org. All Rights Reserved. ========= + +from camel.agents import ChatAgent +from camel.configs import ChatGPTConfig +from camel.models import ModelFactory +from camel.toolkits import SearchToolkit +from camel.types import ModelPlatformType, ModelType + +o3_model = ModelFactory.create( + model_platform=ModelPlatformType.OPENAI, + model_type=ModelType.O3_MINI, + model_config_dict=ChatGPTConfig().as_dict(), +) + + +# Set agent +camel_agent = ChatAgent( + model=o3_model, tools=[SearchToolkit().search_duckduckgo] +) + +# Set user message +user_msg = """Search what is deepseek r1, and do a comparison between deepseek +r1 and openai o3 mini and let me know the advantages and disadvantages of +openai o3 mini""" + +# Get response information +response = camel_agent.step(user_msg) +print(str(response.info['tool_calls'])[:1000]) +''' +=============================================================================== +[FunctionCallingRecord(func_name='search_duckduckgo', args={'query': 'what is +deepseek r1, and do a comparison between deepseek r1 and openai o3 mini', +'source': 'text', 'max_results': 5}, result=[{'result_id': 1, 'title': +'DeepSeek R1 vs OpenAI o1: Which One is Better? - Analytics Vidhya', +'description': "The DeepSeek R1 has arrived, and it's not just another AI +model—it's a significant leap in AI capabilities, trained upon the previously +released DeepSeek-V3-Base variant.With the full-fledged release of DeepSeek +R1, it now stands on par with OpenAI o1 in both performance and flexibility. +What makes it even more compelling is its open weight and MIT licensing, +making it commercially ...", 'url': 'https://www.analyticsvidhya.com/blog/2025/ +01/deepseek-r1-vs-openai-o1/'}, {'result_id': 2, 'title': 'DeepSeek-R1: +Features, Use Cases, and Comparison with OpenAI', 'description': 'Where +DeepSeek Shines: Mathematical reasoning and code generation, thanks to +RL-driven CoT.; Where OpenAI Has an... +=============================================================================== +''' +print(response.msgs[0].content) +# ruff: noqa: RUF001, E501 +''' +=============================================================================== +Below is an overview of DeepSeek R1, followed by a comparative analysis with OpenAI’s o3-mini model. + +• What is DeepSeek R1? +DeepSeek R1 is an AI model that represents a significant leap in reasoning and language capabilities. It stems from prior iterations like DeepSeek-V3-Base but incorporates additional supervised fine-tuning, enabling improvements in mathematical reasoning, logic, and code generation. One of its major selling points is its open nature—released with an open license (MIT) and open weights—making it highly attractive for research, customization, and commercial applications without the traditional licensing barriers. It has been praised for its affordability (with API usage that can be many times cheaper than some competing models) and has been shown on several benchmarks to hold its own against established models. + +• What is OpenAI’s o3-mini? +OpenAI’s o3-mini is part of OpenAI’s reasoning model series and is designed to deliver robust performance specifically in STEM areas such as science, mathematics, and coding. Announced as a response to emerging competition (including DeepSeek R1), o3-mini emphasizes cost efficiency while providing competitive reasoning capabilities. It’s integrated into the ChatGPT ecosystem (with availability on ChatGPT’s enterprise and education platforms) and positions itself as a compact yet powerful option that delivers high-quality reasoning at a lower cost than some earlier OpenAI versions. + +• Comparing DeepSeek R1 and OpenAI o3-mini: + +1. Performance & Capabilities + – Both models are geared toward advanced reasoning tasks, including problem-solving in STEM subjects and code generation. + – DeepSeek R1 has been lauded for its performance enhancements over previous iterations (especially in areas like mathematical reasoning) thanks to intensive fine-tuning, while independent evaluations have pitted it against other high-end models. + – OpenAI o3-mini is tuned to deliver high-quality reasoning with a focus on speed and cost-effectiveness, often showing particularly strong results in STEM benchmarks. + +2. Accessibility and Licensing + – DeepSeek R1 is open source with an MIT license. Its openly available weights make it especially attractive for academic research, startups, or any developer who prefers customizable and transparent AI tools without prohibitive licensing fees. + – In contrast, OpenAI o3-mini is available via OpenAI’s platforms (such as ChatGPT and its API). Users generally access it through a subscription or pay-as-you-go model, with pricing structured to remain competitive against both previous OpenAI models and the emerging open-source alternatives. + +3. Cost Efficiency + – DeepSeek R1’s open-source nature generally translates into lower entry costs, making it an economical choice for developers and companies that want to deploy advanced reasoning tools without high API fees. + – OpenAI o3-mini, although designed to be more cost-efficient compared to earlier OpenAI releases, is still part of a managed service infrastructure. According to industry reports, it is significantly cheaper (with some mentions of being up to 63% less expensive than some predecessors) and positioned as a competitive alternative in pricing, but it may still come with usage limits tied to subscription tiers. + +4. Ecosystem Integration + – With DeepSeek R1, users have the freedom to run the model in customized environments or integrate it within open-source projects—this flexibility can drive innovation in experimental research or bespoke applications. + – OpenAI o3-mini benefits from OpenAI’s established ecosystem and integration into widely used platforms like ChatGPT Enterprise and Education. Its seamless integration means users can quickly leverage its capabilities without dealing with additional infrastructure setups. + +In summary, while both DeepSeek R1 and OpenAI o3-mini aim to push forward the frontier of reasoning and STEM-focused AI models, they serve slightly different audiences. DeepSeek R1’s open-weight, open-license approach makes it ideal for those prioritizing versatility and low-cost research or customized product development. On the other hand, OpenAI o3-mini leverages OpenAI’s ecosystem to offer a highly optimized, cost-effective model that is integrated directly into widely used interfaces and platforms, providing a more out-of-the-box solution for end users and enterprise clients. +=============================================================================== +''' diff --git a/pyproject.toml b/pyproject.toml index 21e7a0d96e..8b9dfd3369 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,7 +4,7 @@ build-backend = "poetry.core.masonry.api" [tool.poetry] name = "camel-ai" -version = "0.2.18" +version = "0.2.19" authors = ["CAMEL-AI.org"] description = "Communicative Agents for AI Society Study" readme = "README.md"