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

feat: Add claude 3.5, update interface for zhipu example (#669)

Wendong-Fana42d0291c45e
diff --git a/camel/types/enums.py b/camel/types/enums.py
index 5bdfbf3a2..7d00e88c8 100644
--- a/camel/types/enums.py
+++ b/camel/types/enums.py
@@ -49,6 +49,7 @@ class ModelType(Enum):
CLAUDE_3_OPUS = "claude-3-opus-20240229"
CLAUDE_3_SONNET = "claude-3-sonnet-20240229"
CLAUDE_3_HAIKU = "claude-3-haiku-20240307"
+ CLAUDE_3_5_SONNET = "claude-3-5-sonnet-20240620"
# Nvidia models
NEMOTRON_4_REWARD = "nvidia/nemotron-4-340b-reward"
@@ -104,6 +105,7 @@ class ModelType(Enum):
ModelType.CLAUDE_3_OPUS,
ModelType.CLAUDE_3_SONNET,
ModelType.CLAUDE_3_HAIKU,
+ ModelType.CLAUDE_3_5_SONNET,
}
@property
@@ -155,6 +157,7 @@ class ModelType(Enum):
ModelType.CLAUDE_3_OPUS,
ModelType.CLAUDE_3_SONNET,
ModelType.CLAUDE_3_HAIKU,
+ ModelType.CLAUDE_3_5_SONNET,
}:
return 200_000
elif self is ModelType.NEMOTRON_4_REWARD:
diff --git a/examples/models/zhipuai_model_example copy.py b/examples/models/zhipuai_model_example.py
similarity index 92%
rename from examples/models/zhipuai_model_example copy.py
rename to examples/models/zhipuai_model_example.py
index 72cfbadc4..9715fde49 100644
--- a/examples/models/zhipuai_model_example copy.py
+++ b/examples/models/zhipuai_model_example.py
@@ -15,7 +15,14 @@
from camel.agents import ChatAgent
from camel.configs import ChatGPTConfig
from camel.messages import BaseMessage
-from camel.types import ModelType
+from camel.models import ModelFactory
+from camel.types import ModelPlatformType, ModelType
+
+model = ModelFactory.create(
+ model_platform=ModelPlatformType.ZHIPU,
+ model_type=ModelType.GLM_4,
+ model_config=ChatGPTConfig(temperature=0.2),
+)
# Define system message
sys_msg = BaseMessage.make_assistant_message(
@@ -23,18 +30,8 @@ sys_msg = BaseMessage.make_assistant_message(
content="You are a helpful assistant.",
)
-# Set model config
-model_config = ChatGPTConfig(
- temperature=0.2, top_p=0.9
-) # temperature=,top_p here can not be 1 or 0.
-
# Set agent
-camel_agent = ChatAgent(
- sys_msg,
- model_config=model_config,
- model_type=ModelType.GLM_4,
-)
-camel_agent.reset()
+camel_agent = ChatAgent(system_message=sys_msg, model=model)
user_msg = BaseMessage.make_user_message(
role_name="User",
diff --git a/poetry.lock b/poetry.lock
index 67682e493..571ae688b 100644
--- a/poetry.lock
+++ b/poetry.lock
@@ -218,13 +218,13 @@ typing-extensions = {version = ">=4.0.0", markers = "python_version < \"3.9\""}
[[package]]
name = "anthropic"
-version = "0.28.1"
+version = "0.29.0"
description = "The official Python library for the anthropic API"
optional = false
python-versions = ">=3.7"
files = [
- {file = "anthropic-0.28.1-py3-none-any.whl", hash = "sha256:c4773ae2b42951a6b747bed328b0d03fa412938c95c3a8b9dce70d69badb710b"},
- {file = "anthropic-0.28.1.tar.gz", hash = "sha256:e3a6d595bde241141bdc685edc393903ec95c7fa378013a71186cfb8f32b1793"},
+ {file = "anthropic-0.29.0-py3-none-any.whl", hash = "sha256:d16010715129c8bc3295b74fbf4da73cfb156618bf0abb2d007255983266b76a"},
+ {file = "anthropic-0.29.0.tar.gz", hash = "sha256:3eb558a232d83bdf7cdedb75663bf7ff7a8b50cc10acaa9ce6494ff295b8506a"},
]
[package.dependencies]
@@ -7631,4 +7631,4 @@ vector-databases = ["pymilvus", "qdrant-client"]
[metadata]
lock-version = "2.0"
python-versions = ">=3.8.1,<3.12"
-content-hash = "eb6da340e8bcf87e611d81f81ddde8998c8edeb17b00177719e151ec992b1b48"
+content-hash = "21adba18eafa5a5ebe06249225548680380aa8d5ab740890015e78d03c06892a"
diff --git a/pyproject.toml b/pyproject.toml
index 723e0e3d9..1f585d0e1 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -35,7 +35,7 @@ colorama = "^0"
jsonschema = "^4"
protobuf = "^4"
pathlib = "^1.0.1"
-anthropic = "^0.28.0"
+anthropic = "^0.29.0"
docstring-parser = "^0.15"
pydantic = ">=1.9,<3"
curl_cffi = "0.6.2"
diff --git a/test/models/test_anthropic_model.py b/test/models/test_anthropic_model.py
index 178963b7e..6ea732011 100644
--- a/test/models/test_anthropic_model.py
+++ b/test/models/test_anthropic_model.py
@@ -31,6 +31,7 @@ from camel.utils import AnthropicTokenCounter
ModelType.CLAUDE_3_OPUS,
ModelType.CLAUDE_3_SONNET,
ModelType.CLAUDE_3_HAIKU,
+ ModelType.CLAUDE_3_5_SONNET,
],
)
def test_anthropic_model(model_type):