Skip to content

Commit

Permalink
feat: Add claude 3.5, update interface for zhipu example (#669)
Browse files Browse the repository at this point in the history
  • Loading branch information
Wendong-Fan authored Jun 21, 2024
1 parent 0e562bc commit a42d029
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 17 deletions.
3 changes: 3 additions & 0 deletions camel/types/enums.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -104,6 +105,7 @@ def is_anthropic(self) -> bool:
ModelType.CLAUDE_3_OPUS,
ModelType.CLAUDE_3_SONNET,
ModelType.CLAUDE_3_HAIKU,
ModelType.CLAUDE_3_5_SONNET,
}

@property
Expand Down Expand Up @@ -155,6 +157,7 @@ def token_limit(self) -> int:
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:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,26 +15,23 @@
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(
role_name="Assistant",
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",
Expand Down
8 changes: 4 additions & 4 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
1 change: 1 addition & 0 deletions test/models/test_anthropic_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
ModelType.CLAUDE_3_OPUS,
ModelType.CLAUDE_3_SONNET,
ModelType.CLAUDE_3_HAIKU,
ModelType.CLAUDE_3_5_SONNET,
],
)
def test_anthropic_model(model_type):
Expand Down

0 comments on commit a42d029

Please sign in to comment.