diff --git a/camel/types/enums.py b/camel/types/enums.py index 7c0a94d5ce..e05ee90978 100644 --- a/camel/types/enums.py +++ b/camel/types/enums.py @@ -50,6 +50,7 @@ class ModelType(UnifiedModelType, Enum): O3 = "o3" O3_PRO = "o3-pro" GPT_5_1 = "gpt-5.1" + GPT_5_2 = ("gpt-5.2",) GPT_5 = "gpt-5" GPT_5_MINI = "gpt-5-mini" GPT_5_NANO = "gpt-5-nano" @@ -597,6 +598,7 @@ def is_openai(self) -> bool: ModelType.O4_MINI, ModelType.O3, ModelType.GPT_5_1, + ModelType.GPT_5_2, } @property @@ -1542,6 +1544,7 @@ def token_limit(self) -> int: return 320_000 elif self in { ModelType.GPT_5_1, + ModelType.GPT_5_2, ModelType.GPT_5_MINI, ModelType.GPT_5_NANO, ModelType.GPT_5, diff --git a/examples/models/openai_gpt_5_example.py b/examples/models/openai_example.py similarity index 57% rename from examples/models/openai_gpt_5_example.py rename to examples/models/openai_example.py index adf6b24163..337947afd4 100644 --- a/examples/models/openai_gpt_5_example.py +++ b/examples/models/openai_example.py @@ -15,28 +15,52 @@ from camel.agents import ChatAgent from camel.configs import ChatGPTConfig from camel.models import ModelFactory +from camel.toolkits import TerminalToolkit from camel.types import ModelPlatformType, ModelType +tools = [ + *TerminalToolkit().get_tools(), +] + gpt_5_model = ModelFactory.create( model_platform=ModelPlatformType.OPENAI, - model_type=ModelType.GPT_5, + model_type=ModelType.GPT_5_2, model_config_dict=ChatGPTConfig().as_dict(), ) # Set agent -camel_agent = ChatAgent(model=gpt_5_model) +camel_agent = ChatAgent(model=gpt_5_model, tools=tools) # Set user message -user_msg = """Say hi to CAMEL AI, one open-source community - dedicated to the study of autonomous and communicative agents.""" +user_msg = """Use tool to create an interactive HTML webpage that allows users +to play with a Rubik's Cube, and saved it to local file. +""" # Get response information response = camel_agent.step(user_msg) print(response.msgs[0].content) ''' =============================================================================== -Hello, CAMEL AI! Great to connect with an open-source community advancing -autonomous and communicative agents. Wishing you continued success—excited to -see what you build next! +Created an interactive Rubik's Cube webpage and saved it locally as: + +- `rubiks_cube.html` + +It includes: +- 3D cube rendering (drag to orbit, wheel to zoom) +- Face turns via buttons or keyboard (U/D/L/R/F/B, Shift for prime) +- Scramble, reset, random move +- Undo/redo +- Copyable moves log + +Open it by double-clicking the file or serving it locally +(recommended due to browser module/security policies): + +```bash +python3 -m http.server +# then visit http://localhost:8000/rubiks_cube.html +``` + +If you want a **fully offline** version (no CDN usage), tell me and +I'll modify it to bundle the required libraries locally or inline them. =============================================================================== ''' diff --git a/examples/models/openai_gpt_4.1_example.py b/examples/models/openai_gpt_4.1_example.py deleted file mode 100644 index e2980e4ed5..0000000000 --- a/examples/models/openai_gpt_4.1_example.py +++ /dev/null @@ -1,44 +0,0 @@ -# ========= 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.types import ModelPlatformType, ModelType - -gpt_4_1_model = ModelFactory.create( - model_platform=ModelPlatformType.OPENAI, - model_type=ModelType.GPT_4_1, - model_config_dict=ChatGPTConfig().as_dict(), -) - -# Set agent -camel_agent = ChatAgent(model=gpt_4_1_model) - -# Set user message -user_msg = """Say hi to CAMEL AI, one open-source community - dedicated to the study of autonomous and communicative agents.""" - -# Get response information -response = camel_agent.step(user_msg) -print(response.msgs[0].content) -''' -=============================================================================== -Hi CAMEL AI! 👋 It's great to see an open-source community dedicated to -advancing the study of autonomous and communicative agents. Your efforts help -push the boundaries of what's possible in AI collaboration and agentic -systems. Looking forward to seeing the innovations and insights your community -brings to the field! 🚀 -=============================================================================== -''' diff --git a/examples/models/openai_gpt_4.5_preview_example.py b/examples/models/openai_gpt_4.5_preview_example.py deleted file mode 100644 index e69d98e481..0000000000 --- a/examples/models/openai_gpt_4.5_preview_example.py +++ /dev/null @@ -1,94 +0,0 @@ -# ========= 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.types import ModelPlatformType, ModelType - -gpt_4_5_preview_model = ModelFactory.create( - model_platform=ModelPlatformType.OPENAI, - model_type=ModelType.GPT_4_5_PREVIEW, - model_config_dict=ChatGPTConfig().as_dict(), -) - -# Set agent -camel_agent = ChatAgent(model=gpt_4_5_preview_model) - -# Set user message -user_msg = """Please write inspirational poems -that make people feel hopeful and enthusiastic about life""" - -# Get response information -response = camel_agent.step(user_msg) -print(response.msgs[0].content) -''' -=============================================================================== - -### Poem 1: Embrace the Dawn - -Awaken now, the dawn is near, -A fresh new day, release your fear. -Yesterday's shadows fade away, -Hope blooms bright, embrace today. - -Rise with courage, dreams in sight, -Your heart ablaze, your spirit bright. -Each step forward, strength you find, -A brighter future, yours to bind. - -Believe in you, your path is clear, -Trust your journey, hold it dear. -Life's beauty shines, a guiding star, -You're stronger now than ever you are. - ---- - -### Poem 2: The Power Within - -Within your heart, a spark resides, -A strength that never truly hides. -Through storms and trials, you will rise, -With hope and courage in your eyes. - -Your dreams are seeds, plant them deep, -Nurture faith, your promise keep. -Life's journey vast, adventure grand, -Hold tight to hope, take life's hand. - -Enthusiasm fuels your way, -Brightens every single day. -Believe, persist, your spirit free, -The power within—your destiny. - ---- - -### Poem 3: A New Beginning - -Each sunrise brings a fresh new start, -A chance to heal, renew your heart. -Let go of doubts, embrace the light, -Your future shines, forever bright. - -Life's canvas blank, your colors bold, -Paint your dreams, let joy unfold. -Hope whispers softly, "You can soar," -Open wide life's wondrous door. - -Enthusiasm fills your soul, -Guiding you toward your goal. -With hope alive, your spirit strong, -Life's melody—your hopeful song. -=============================================================================== -''' diff --git a/examples/models/openai_o1_example.py b/examples/models/openai_o1_example.py deleted file mode 100644 index 5a3583acba..0000000000 --- a/examples/models/openai_o1_example.py +++ /dev/null @@ -1,173 +0,0 @@ -# ========= 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.types import ModelPlatformType, ModelType - -o1_model = ModelFactory.create( - model_platform=ModelPlatformType.OPENAI, - model_type=ModelType.O1_MINI, # Or ModelType.O1 - model_config_dict=ChatGPTConfig().as_dict(), -) - -# Set agent -camel_agent = ChatAgent(model=o1_model) - -# Set user message -user_msg = """Write a bash script that takes a matrix represented as a string - with format '[1,2],[3,4],[5,6]' and prints the transpose in the same - format.""" - -# Get response information -response = camel_agent.step(user_msg) -print(response.msgs[0].content) -''' -=============================================================================== -Here's a bash script that transposes a matrix represented as the string format -specified. It handles matrices of various sizes, including those with varying -numbers of columns. - -```bash -#!/bin/bash - -# Read input string from argument or stdin -if [ -n "$1" ]; then - input="$1" -else - read input -fi - -# Preprocess the input string to facilitate parsing -# Replace '],[' with '];[' to use ';' as row separator -input="${input//],[/];[}" - -# Remove leading and trailing square brackets if any -input="${input#[}" -input="${input%]}" - -# Split the input into rows -IFS=';' read -ra rows <<< "$input" - -declare -A matrix - -nrows=${#rows[@]} -ncols=0 - -# Parse each row -for ((i=0; i ncols )); then - ncols=$num_elems - fi - # Store elements in matrix associative array - for ((j=0; j