Skip to content

Commit

Permalink
feat: Support openai o1 models (#936)
Browse files Browse the repository at this point in the history
  • Loading branch information
Wendong-Fan authored Sep 12, 2024
1 parent 5037f68 commit a00fb77
Show file tree
Hide file tree
Showing 10 changed files with 379 additions and 350 deletions.
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE/bug_report.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,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.1.8
placeholder: E.g., 0.1.9
validations:
required: true

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ conda create --name camel python=3.10
conda activate camel

# Clone github repo
git clone -b v0.1.8 https://github.com/camel-ai/camel.git
git clone -b v0.1.9 https://github.com/camel-ai/camel.git

# Change directory into project directory
cd camel
Expand Down
2 changes: 1 addition & 1 deletion camel/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
# limitations under the License.
# =========== Copyright 2023 @ CAMEL-AI.org. All Rights Reserved. ===========

__version__ = '0.1.8'
__version__ = '0.1.9'

__all__ = [
'__version__',
Expand Down
6 changes: 6 additions & 0 deletions camel/types/enums.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ class ModelType(Enum):
GPT_4_TURBO = "gpt-4-turbo"
GPT_4O = "gpt-4o"
GPT_4O_MINI = "gpt-4o-mini"
O1_PREVIEW = "o1-preview"
O1_MINI = "o1-mini"

GLM_4 = "glm-4"
GLM_4_OPEN_SOURCE = "glm-4-open-source"
Expand Down Expand Up @@ -105,6 +107,8 @@ def is_openai(self) -> bool:
ModelType.GPT_4_TURBO,
ModelType.GPT_4O,
ModelType.GPT_4O_MINI,
ModelType.O1_PREVIEW,
ModelType.O1_MINI,
}

@property
Expand Down Expand Up @@ -270,6 +274,8 @@ def token_limit(self) -> int:
ModelType.GPT_4O,
ModelType.GPT_4O_MINI,
ModelType.GPT_4_TURBO,
ModelType.O1_PREVIEW,
ModelType.O1_MINI,
ModelType.MISTRAL_LARGE,
ModelType.MISTRAL_NEMO,
ModelType.QWEN_2,
Expand Down
3 changes: 3 additions & 0 deletions camel/utils/token_counting.py
Original file line number Diff line number Diff line change
Expand Up @@ -288,6 +288,9 @@ def __init__(self, model: ModelType):
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:
self.tokens_per_message = 2
self.tokens_per_name = 1
else:
# flake8: noqa :E501
raise NotImplementedError(
Expand Down
2 changes: 1 addition & 1 deletion docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
project = 'CAMEL'
copyright = '2023, CAMEL-AI.org'
author = 'CAMEL-AI.org'
release = '0.1.8'
release = '0.1.9'

html_favicon = (
'https://raw.githubusercontent.com/camel-ai/camel/master/misc/favicon.png'
Expand Down
2 changes: 1 addition & 1 deletion docs/get_started/setup.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ conda create --name camel python=3.10
conda activate camel

# Clone github repo
git clone -b v0.1.8 https://github.com/camel-ai/camel.git
git clone -b v0.1.9 https://github.com/camel-ai/camel.git

# Change directory into project directory
cd camel
Expand Down
704 changes: 361 additions & 343 deletions poetry.lock

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ build-backend = "poetry.core.masonry.api"

[tool.poetry]
name = "camel-ai"
version = "0.1.8"
version = "0.1.9"
authors = ["CAMEL-AI.org"]
description = "Communicative Agents for AI Society Study"
readme = "README.md"
Expand All @@ -29,7 +29,7 @@ documentation = "https://docs.camel-ai.org"
[tool.poetry.dependencies]
python = ">=3.10.0,<3.12"
numpy = "^1"
openai = "^1.2.3"
openai = "^1.45.0"
groq = "^0.5.0"
anthropic = "^0.29.0"
tiktoken = "^0.7.0"
Expand Down
2 changes: 2 additions & 0 deletions test/models/test_openai_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@
ModelType.GPT_4_TURBO,
ModelType.GPT_4O,
ModelType.GPT_4O_MINI,
ModelType.O1_PREVIEW,
ModelType.O1_MINI,
],
)
def test_openai_model(model_type):
Expand Down

0 comments on commit a00fb77

Please sign in to comment.