Skip to content

Commit 33427e1

Browse files
authored
feat: Support Claude Opus 4.5 (#3450)
1 parent 262a1ed commit 33427e1

File tree

3 files changed

+82
-5
lines changed

3 files changed

+82
-5
lines changed

camel/types/enums.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -216,6 +216,7 @@ class ModelType(UnifiedModelType, Enum):
216216
CLAUDE_3_5_HAIKU = "claude-3-5-haiku-latest"
217217
CLAUDE_3_7_SONNET = "claude-3-7-sonnet-latest"
218218
CLAUDE_SONNET_4_5 = "claude-sonnet-4-5"
219+
CLAUDE_OPUS_4_5 = "claude-opus-4-5"
219220
CLAUDE_SONNET_4 = "claude-sonnet-4-20250514"
220221
CLAUDE_OPUS_4 = "claude-opus-4-20250514"
221222
CLAUDE_OPUS_4_1 = "claude-opus-4-1-20250805"
@@ -685,6 +686,7 @@ def is_anthropic(self) -> bool:
685686
ModelType.CLAUDE_3_5_HAIKU,
686687
ModelType.CLAUDE_3_7_SONNET,
687688
ModelType.CLAUDE_SONNET_4_5,
689+
ModelType.CLAUDE_OPUS_4_5,
688690
ModelType.CLAUDE_SONNET_4,
689691
ModelType.CLAUDE_OPUS_4,
690692
ModelType.CLAUDE_OPUS_4_1,
@@ -1521,6 +1523,7 @@ def token_limit(self) -> int:
15211523
ModelType.CLAUDE_3_5_HAIKU,
15221524
ModelType.CLAUDE_3_7_SONNET,
15231525
ModelType.CLAUDE_SONNET_4_5,
1526+
ModelType.CLAUDE_OPUS_4_5,
15241527
ModelType.CLAUDE_SONNET_4,
15251528
ModelType.CLAUDE_OPUS_4,
15261529
ModelType.CLAUDE_OPUS_4_1,

examples/models/claude_4_5_sonnet_example.py renamed to examples/models/claude_model_example.py

Lines changed: 78 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,29 +12,102 @@
1212
# limitations under the License.
1313
# ========= Copyright 2023-2024 @ CAMEL-AI.org. All Rights Reserved. =========
1414

15+
import os
16+
1517
from camel.agents import ChatAgent
1618
from camel.configs import AnthropicConfig
1719
from camel.models import ModelFactory
18-
from camel.toolkits import FunctionTool
20+
from camel.toolkits import FunctionTool, TerminalToolkit
1921
from camel.types import ModelPlatformType, ModelType
2022

2123
"""
22-
Claude Sonnet 4.5 Example
24+
Claude Model Example
2325
2426
Please set the environment variable:
2527
export ANTHROPIC_API_KEY="your-api-key-here"
2628
"""
2729

30+
# Define system message
31+
sys_msg = "You are a helpful AI assistant"
32+
33+
# Get current script directory
34+
base_dir = os.path.dirname(os.path.abspath(__file__))
35+
# Define workspace directory for the toolkit
36+
workspace_dir = os.path.join(
37+
os.path.dirname(os.path.dirname(base_dir)), "workspace"
38+
)
39+
40+
# Set model config
41+
tools = [
42+
*TerminalToolkit(working_directory=workspace_dir).get_tools(),
43+
]
44+
# Create Claude Opus 4.5 model
45+
model_opus_4_5 = ModelFactory.create(
46+
model_platform=ModelPlatformType.ANTHROPIC,
47+
model_type=ModelType.CLAUDE_OPUS_4_5,
48+
model_config_dict=AnthropicConfig(temperature=0.2).as_dict(),
49+
)
50+
51+
user_msg = """
52+
Create an interactive HTML webpage that allows users to play with a
53+
Rubik's Cube, and saved it to local file.
54+
"""
55+
56+
camel_agent_pro = ChatAgent(
57+
system_message=sys_msg, model=model_opus_4_5, tools=tools
58+
)
59+
response_pro = camel_agent_pro.step(user_msg)
60+
print(response_pro.msgs[0].content)
61+
'''
62+
===============================================================================
63+
The interactive Rubik's Cube HTML file has been created successfully! Here's
64+
what I built:
65+
66+
## 📁 File: `rubiks_cube.html` (23KB)
67+
68+
### Features:
69+
70+
🎮 **Interactive 3D Cube**
71+
- Fully rendered 3D Rubik's Cube using CSS transforms
72+
- Drag to rotate the view (mouse or touch)
73+
- All 6 faces visible with proper colors
74+
75+
🔄 **Face Rotations**
76+
- **F/B** - Front/Back face
77+
- **U/D** - Up/Down face
78+
- **L/R** - Left/Right face
79+
- **'** versions for counter-clockwise rotations
80+
81+
⚡ **Actions**
82+
- **Scramble** - Randomly mix the cube with 20 moves
83+
- **Reset** - Return to solved state
84+
- **Undo** - Reverse the last move
85+
86+
📐 **Net View**
87+
- 2D unfolded view of all cube faces for easier tracking
88+
89+
⌨️ **Keyboard Support**
90+
- Press F, B, R, L, U, D keys to rotate faces
91+
- Hold Shift for counter-clockwise
92+
93+
📱 **Responsive Design**
94+
- Works on desktop and mobile devices
95+
- Touch support for rotating the view
96+
97+
### To use:
98+
Simply open `rubiks_cube.html` in any modern web browser!
99+
100+
Process finished with exit code 0
101+
===============================================================================
102+
'''
103+
28104
# Create Claude Sonnet 4.5 model
29105
model = ModelFactory.create(
30106
model_platform=ModelPlatformType.ANTHROPIC,
31107
model_type=ModelType.CLAUDE_SONNET_4_5,
32108
model_config_dict=AnthropicConfig(temperature=0.2).as_dict(),
33109
)
34110

35-
# Define system message
36-
sys_msg = "You are a helpful AI assistant powered by Claude Sonnet 4.5."
37-
38111
# Set agent
39112
camel_agent = ChatAgent(system_message=sys_msg, model=model)
40113

test/models/test_anthropic_model.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
ModelType.CLAUDE_3_5_HAIKU,
3535
ModelType.CLAUDE_3_7_SONNET,
3636
ModelType.CLAUDE_SONNET_4_5,
37+
ModelType.CLAUDE_OPUS_4_5,
3738
ModelType.CLAUDE_SONNET_4,
3839
ModelType.CLAUDE_OPUS_4,
3940
ModelType.CLAUDE_OPUS_4_1,

0 commit comments

Comments
 (0)