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: Support Gemini 2.5 pro (#1995)

Wendong-Fan2d31dda08e8c
diff --git a/.github/ISSUE_TEMPLATE/bug_report.yml b/.github/ISSUE_TEMPLATE/bug_report.yml
index 5877b53ab..cfac98fb0 100644
--- a/.github/ISSUE_TEMPLATE/bug_report.yml
+++ b/.github/ISSUE_TEMPLATE/bug_report.yml
@@ -26,7 +26,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.2.36
+ placeholder: E.g., 0.2.37
validations:
required: true
diff --git a/camel/__init__.py b/camel/__init__.py
index e1cfb5ad6..ab9e34193 100644
--- a/camel/__init__.py
+++ b/camel/__init__.py
@@ -14,7 +14,7 @@
from camel.logger import disable_logging, enable_logging, set_log_level
-__version__ = '0.2.36'
+__version__ = '0.2.37'
__all__ = [
'__version__',
diff --git a/camel/types/enums.py b/camel/types/enums.py
index fa3da99b7..2081f737d 100644
--- a/camel/types/enums.py
+++ b/camel/types/enums.py
@@ -123,6 +123,7 @@ class ModelType(UnifiedModelType, Enum):
NVIDIA_LLAMA3_3_70B_INSTRUCT = "meta/llama-3.3-70b-instruct"
# Gemini models
+ GEMINI_2_5_PRO_EXP = "gemini-2.5-pro-exp-03-25"
GEMINI_2_0_FLASH = "gemini-2.0-flash-exp"
GEMINI_2_0_FLASH_THINKING = "gemini-2.0-flash-thinking-exp"
GEMINI_2_0_PRO_EXP = "gemini-2.0-pro-exp-02-05"
@@ -420,6 +421,7 @@ class ModelType(UnifiedModelType, Enum):
bool: Whether this type of models is gemini.
"""
return self in {
+ ModelType.GEMINI_2_5_PRO_EXP,
ModelType.GEMINI_2_0_FLASH,
ModelType.GEMINI_1_5_FLASH,
ModelType.GEMINI_1_5_PRO,
@@ -724,6 +726,7 @@ class ModelType(UnifiedModelType, Enum):
}:
return 256_000
elif self in {
+ ModelType.GEMINI_2_5_PRO_EXP,
ModelType.GEMINI_2_0_FLASH,
ModelType.GEMINI_1_5_FLASH,
ModelType.GEMINI_1_5_PRO,
diff --git a/docs/conf.py b/docs/conf.py
index 97f567384..f12051b6b 100644
--- a/docs/conf.py
+++ b/docs/conf.py
@@ -27,7 +27,7 @@ sys.path.insert(0, os.path.abspath('..'))
project = 'CAMEL'
copyright = '2024, CAMEL-AI.org'
author = 'CAMEL-AI.org'
-release = '0.2.36'
+release = '0.2.37'
html_favicon = (
'https://raw.githubusercontent.com/camel-ai/camel/master/misc/favicon.png'
diff --git a/docs/key_modules/loaders.md b/docs/key_modules/loaders.md
index 9f9b7c56f..af2c4887b 100644
--- a/docs/key_modules/loaders.md
+++ b/docs/key_modules/loaders.md
@@ -340,14 +340,14 @@ response = jina_reader.read_content("https://docs.camel-ai.org/")
print(response)
```
```markdown
->>>Welcome to CAMEL’s documentation! — CAMEL 0.2.36 documentation
+>>>Welcome to CAMEL’s documentation! — CAMEL 0.2.37 documentation
===============
[Skip to main content](https://docs.camel-ai.org/#main-content)
Back to top Ctrl+K
- [![Image 1](https://raw.githubusercontent.com/camel-ai/camel/master/misc/logo_light.png) ![Image 2](https://raw.githubusercontent.com/camel-ai/camel/master/misc/logo_light.png)CAMEL 0.2.36](https://docs.camel-ai.org/#)
+ [![Image 1](https://raw.githubusercontent.com/camel-ai/camel/master/misc/logo_light.png) ![Image 2](https://raw.githubusercontent.com/camel-ai/camel/master/misc/logo_light.png)CAMEL 0.2.37](https://docs.camel-ai.org/#)
Search Ctrl+K
diff --git a/examples/models/gemini_model_example.py b/examples/models/gemini_model_example.py
index 0c0b74150..955b2526b 100644
--- a/examples/models/gemini_model_example.py
+++ b/examples/models/gemini_model_example.py
@@ -16,21 +16,43 @@ from camel.configs import GeminiConfig
from camel.models import ModelFactory
from camel.types import ModelPlatformType, ModelType
+# Define system message
+sys_msg = "You are a helpful assistant."
+
+# User message
+user_msg = """Say hi to CAMEL AI, one open-source community dedicated to the
+ study of autonomous and communicative agents."""
+
+# Example of using the gemini-2.5-pro-exp model
+model_2_5_pro_exp = ModelFactory.create(
+ model_platform=ModelPlatformType.GEMINI,
+ model_type=ModelType.GEMINI_2_5_PRO_EXP,
+ model_config_dict=GeminiConfig(temperature=0.2).as_dict(),
+)
+camel_agent_pro = ChatAgent(system_message=sys_msg, model=model_2_5_pro_exp)
+response_pro = camel_agent_pro.step(user_msg)
+print(response_pro.msgs[0].content)
+'''
+===============================================================================
+Hello CAMEL AI! 👋
+
+It's great to acknowledge your open-source community and your important
+dedication to the study of autonomous and communicative agents. That's a
+fascinating and crucial area of research! Wishing you all the best in your
+endeavors.
+===============================================================================
+'''
+
+# Example of using the gemini-1.5-pro model
model = ModelFactory.create(
model_platform=ModelPlatformType.GEMINI,
model_type=ModelType.GEMINI_1_5_PRO,
model_config_dict=GeminiConfig(temperature=0.2).as_dict(),
)
-# Define system message
-sys_msg = "You are a helpful assistant."
-
# Set agent
camel_agent = ChatAgent(system_message=sys_msg, model=model)
-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)
diff --git a/pyproject.toml b/pyproject.toml
index aeeafb970..e7b722fad 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
[project]
name = "camel-ai"
-version = "0.2.36"
+version = "0.2.37"
description = "Communicative Agents for AI Society Study"
authors = [{ name = "CAMEL-AI.org" }]
requires-python = ">=3.10,<3.13"
@@ -120,7 +120,7 @@ media_tools = [
communication_tools = [
"slack-sdk>=3.27.2,<4",
"slack-bolt>=1.20.1,<2",
- "pygithub>=2.3.0,<3",
+ "pygithub>=2.6.0,<3",
"pyTelegramBotAPI>=4.18.0,<5",
"discord.py>=2.3.2,<3",
"notion-client>=2.2.1,<3",
@@ -219,7 +219,7 @@ all = [
"slack-sdk>=3.27.2,<4",
"slack-bolt>=1.20.1,<2",
"pydub>=0.25.1,<0.26",
- "pygithub>=2.3.0,<3",
+ "pygithub>=2.6.0,<3",
"pyTelegramBotAPI>=4.18.0,<5",
"discord.py>=2.3.2,<3",
"docker>=7.1.0,<8",
diff --git a/test/models/test_gemini_model.py b/test/models/test_gemini_model.py
index 3658df140..2146a6932 100644
--- a/test/models/test_gemini_model.py
+++ b/test/models/test_gemini_model.py
@@ -25,6 +25,7 @@ from camel.utils import OpenAITokenCounter
@pytest.mark.parametrize(
"model_type",
[
+ ModelType.GEMINI_2_5_PRO_EXP,
ModelType.GEMINI_2_0_FLASH,
ModelType.GEMINI_1_5_FLASH,
ModelType.GEMINI_1_5_PRO,
diff --git a/test/toolkits/test_github_toolkit.py b/test/toolkits/test_github_toolkit.py
index 03f810e1c..7eb8b32ff 100644
--- a/test/toolkits/test_github_toolkit.py
+++ b/test/toolkits/test_github_toolkit.py
@@ -14,173 +14,180 @@
from unittest.mock import MagicMock, patch
-from github import Auth, Github
-from github.ContentFile import ContentFile
-
-from camel.toolkits.github_toolkit import GithubToolkit
-
-
[email protected](Github, '__init__', lambda self, *args, **kwargs: None)
[email protected](Github, 'get_repo', return_value=MagicMock())
[email protected](Auth.Token, '__init__', lambda self, *args, **kwargs: None)
-def test_init(mock_get_repo):
- # Call the constructor of the GithubToolkit class
- github_toolkit = GithubToolkit("repo_name", "token")
-
- # Assert that the get_repo method was called with the correct argument
- github_toolkit.github.get_repo.assert_called_once_with("repo_name")
-
-
[email protected](Github, '__init__', lambda self, *args, **kwargs: None)
[email protected](Github, 'get_repo', return_value=MagicMock())
[email protected](Auth.Token, '__init__', lambda self, *args, **kwargs: None)
-def test_get_tools(mock_get_repo):
- # Call the constructor of the GithubToolkit class
- github_toolkit = GithubToolkit("repo_name", "token")
-
- tools = github_toolkit.get_tools()
- assert isinstance(tools, list)
- assert len(tools) > 0
-
-
[email protected](Github, 'get_repo', return_value=MagicMock())
[email protected](Auth.Token, '__init__', lambda self, *args, **kwargs: None)
-def test_create_pull_request(monkeypatch):
- # Call the constructor of the GithubToolkit class
- github_toolkit = GithubToolkit("repo_name", "token")
-
- # Mock the create_pull method of the github_toolkit instance to return a
- # value
- mock_pr_response = MagicMock()
- mock_pr_response.title = """[GitHub Agent] Solved issue: Time complexity
- for product_of_array_except_self.py"""
- mock_pr_response.body = "Fixes #1"
- github_toolkit.repo.create_pull.return_value = mock_pr_response
-
- # Create a MagicMock that mimics ContentFile
- mock_content_file = MagicMock(spec=ContentFile)
- mock_content_file.path = "path/to/file"
- mock_content_file.sha = "dummy_sha"
-
- # Ensure get_contents returns the mocked ContentFile
- github_toolkit.repo.get_contents.return_value = mock_content_file
-
- # Create a pull request
- pr = github_toolkit.create_pull_request(
- file_path="path/to/file",
- branch_name="branch_name",
- new_content="This is the content of the file",
- pr_title="""[GitHub Agent] Solved issue: Time complexity for
- product_of_array_except_self.py""",
- body="Fixes #1",
- )
-
- expected_response = """Title: [GitHub Agent] Solved issue: Time complexity
- for product_of_array_except_self.py\nBody: Fixes #1\n"""
-
- assert (
- pr == expected_response
- ), f"Expected {expected_response}, but got {pr}"
-
-
[email protected](Github, 'get_repo', return_value=MagicMock())
[email protected](Auth.Token, '__init__', lambda self, *args, **kwargs: None)
-def test_get_all_issues(monkeypatch):
- github_toolkit = GithubToolkit("repo_name", "token")
- mock_issue = MagicMock()
- mock_issue.number = 1
- mock_issue.title = "Test Issue"
- github_toolkit.repo.get_issues.return_value = [mock_issue]
-
- issues = github_toolkit.get_issue_list()
-
- expected_issues = [{"number": 1, "title": "Test Issue"}]
- assert (
- issues == expected_issues
- ), f"Expected {expected_issues}, but got {issues}"
-
-
[email protected](Github, 'get_repo', return_value=MagicMock())
[email protected](Auth.Token, '__init__', lambda self, *args, **kwargs: None)
-def test_get_issue_content(monkeypatch):
- github_toolkit = GithubToolkit("repo_name", "token")
- mock_issue = MagicMock()
- mock_issue.body = "Issue content"
- github_toolkit.repo.get_issue.return_value = mock_issue
-
- content = github_toolkit.get_issue_content(1)
- expected_content = "Issue content"
-
- assert (
- content == expected_content
- ), f"Expected {expected_content}, but got {content}"
-
-
[email protected](Github, 'get_repo', return_value=MagicMock())
[email protected](Auth.Token, '__init__', lambda self, *args, **kwargs: None)
-def test_get_all_pull_requests(monkeypatch):
- github_toolkit = GithubToolkit("repo_name", "token")
- mock_pr = MagicMock()
- mock_pr.number = 1
- mock_pr.title = "Test PR"
- github_toolkit.repo.get_pulls.return_value = [mock_pr]
-
- prs = github_toolkit.get_pull_request_list()
- expected_prs = [{"number": 1, "title": "Test PR"}]
-
- assert prs == expected_prs, f"Expected {expected_prs}, but got {prs}"
-
-
[email protected](Github, 'get_repo', return_value=MagicMock())
[email protected](Auth.Token, '__init__', lambda self, *args, **kwargs: None)
-def test_get_pull_request_code(monkeypatch):
- github_toolkit = GithubToolkit("repo_name", "token")
- mock_file = MagicMock()
- mock_file.filename = "file1.py"
- mock_file.patch = "code changes"
- github_toolkit.repo.get_pull.return_value.get_files.return_value = [
- mock_file
- ]
-
- files_changed = github_toolkit.get_pull_request_code(1)
- expected_files = [{"filename": "file1.py", "patch": "code changes"}]
-
- assert (
- files_changed == expected_files
- ), f"Expected {expected_files}, but got {files_changed}"
-
-
[email protected](Github, 'get_repo', return_value=MagicMock())
[email protected](Auth.Token, '__init__', lambda self, *args, **kwargs: None)
-def test_get_pull_request_comments(monkeypatch):
- github_toolkit = GithubToolkit("repo_name", "token")
- mock_comment = MagicMock()
- mock_comment.user.login = "user1"
- mock_comment.body = "Test comment"
- github_toolkit.repo.get_pull.return_value.get_comments.return_value = [
- mock_comment
- ]
-
- comments = github_toolkit.get_pull_request_comments(1)
- expected_comments = [{"user": "user1", "body": "Test comment"}]
-
- assert (
- comments == expected_comments
- ), f"Expected {expected_comments}, but got {comments}"
-
-
[email protected](Github, 'get_repo', return_value=MagicMock())
[email protected](Auth.Token, '__init__', lambda self, *args, **kwargs: None)
-def test_get_all_file_paths(monkeypatch):
- github_toolkit = GithubToolkit("repo_name", "token")
- mock_content = MagicMock()
- mock_content.type = "file"
- mock_content.path = "path/to/file.py"
- github_toolkit.repo.get_contents.return_value = [mock_content]
-
- files = github_toolkit.get_all_file_paths()
- expected_files = ["path/to/file.py"]
-
- assert (
- files == expected_files
- ), f"Expected {expected_files}, but got {files}"
+import pytest
+
+# Skip the entire module if github package is not available
+try:
+ from github import Auth, Github
+ from github.ContentFile import ContentFile
+
+ GITHUB_AVAILABLE = True
+except ImportError:
+ GITHUB_AVAILABLE = False
+
+# Skip reason for when github is not available
+pytestmark = pytest.mark.skipif(
+ not GITHUB_AVAILABLE,
+ reason="GitHub package not installed or dependency issues "
+ "need to be fixed",
+)
+
+if GITHUB_AVAILABLE:
+ from camel.toolkits.github_toolkit import GithubToolkit
+
+ @patch.object(Github, '__init__', lambda self, *args, **kwargs: None)
+ @patch.object(Github, 'get_repo', return_value=MagicMock())
+ @patch.object(Auth.Token, '__init__', lambda self, *args, **kwargs: None)
+ def test_init(mock_get_repo):
+ # Call the constructor of the GithubToolkit class
+ github_toolkit = GithubToolkit("repo_name", "token")
+
+ # Assert that the get_repo method was called with the correct argument
+ github_toolkit.github.get_repo.assert_called_once_with("repo_name")
+
+ @patch.object(Github, '__init__', lambda self, *args, **kwargs: None)
+ @patch.object(Github, 'get_repo', return_value=MagicMock())
+ @patch.object(Auth.Token, '__init__', lambda self, *args, **kwargs: None)
+ def test_get_tools(mock_get_repo):
+ # Call the constructor of the GithubToolkit class
+ github_toolkit = GithubToolkit("repo_name", "token")
+
+ tools = github_toolkit.get_tools()
+ assert isinstance(tools, list)
+ assert len(tools) > 0
+
+ @patch.object(Github, 'get_repo', return_value=MagicMock())
+ @patch.object(Auth.Token, '__init__', lambda self, *args, **kwargs: None)
+ def test_create_pull_request(monkeypatch):
+ # Call the constructor of the GithubToolkit class
+ github_toolkit = GithubToolkit("repo_name", "token")
+
+ # Mock the create_pull method of the github_toolkit instance to return
+ # a value
+ mock_pr_response = MagicMock()
+ mock_pr_response.title = """[GitHub Agent] Solved issue: Time
+ complexity for product_of_array_except_self.py"""
+ mock_pr_response.body = "Fixes #1"
+ github_toolkit.repo.create_pull.return_value = mock_pr_response
+
+ # Create a MagicMock that mimics ContentFile
+ mock_content_file = MagicMock(spec=ContentFile)
+ mock_content_file.path = "path/to/file"
+ mock_content_file.sha = "dummy_sha"
+
+ # Ensure get_contents returns the mocked ContentFile
+ github_toolkit.repo.get_contents.return_value = mock_content_file
+
+ # Create a pull request
+ pr = github_toolkit.create_pull_request(
+ file_path="path/to/file",
+ branch_name="branch_name",
+ new_content="This is the content of the file",
+ pr_title="""[GitHub Agent] Solved issue: Time complexity for
+ product_of_array_except_self.py""",
+ body="Fixes #1",
+ )
+
+ expected_response = """Title: [GitHub Agent] Solved issue: Time
+ complexity for product_of_array_except_self.py\nBody: Fixes #1\n"""
+
+ assert (
+ pr == expected_response
+ ), f"Expected {expected_response}, but got {pr}"
+
+ @patch.object(Github, 'get_repo', return_value=MagicMock())
+ @patch.object(Auth.Token, '__init__', lambda self, *args, **kwargs: None)
+ def test_get_all_issues(monkeypatch):
+ github_toolkit = GithubToolkit("repo_name", "token")
+ mock_issue = MagicMock()
+ mock_issue.number = 1
+ mock_issue.title = "Test Issue"
+ github_toolkit.repo.get_issues.return_value = [mock_issue]
+
+ issues = github_toolkit.get_issue_list()
+
+ expected_issues = [{"number": 1, "title": "Test Issue"}]
+ assert (
+ issues == expected_issues
+ ), f"Expected {expected_issues}, but got {issues}"
+
+ @patch.object(Github, 'get_repo', return_value=MagicMock())
+ @patch.object(Auth.Token, '__init__', lambda self, *args, **kwargs: None)
+ def test_get_issue_content(monkeypatch):
+ github_toolkit = GithubToolkit("repo_name", "token")
+ mock_issue = MagicMock()
+ mock_issue.body = "Issue content"
+ github_toolkit.repo.get_issue.return_value = mock_issue
+
+ content = github_toolkit.get_issue_content(1)
+ expected_content = "Issue content"
+
+ assert (
+ content == expected_content
+ ), f"Expected {expected_content}, but got {content}"
+
+ @patch.object(Github, 'get_repo', return_value=MagicMock())
+ @patch.object(Auth.Token, '__init__', lambda self, *args, **kwargs: None)
+ def test_get_all_pull_requests(monkeypatch):
+ github_toolkit = GithubToolkit("repo_name", "token")
+ mock_pr = MagicMock()
+ mock_pr.number = 1
+ mock_pr.title = "Test PR"
+ github_toolkit.repo.get_pulls.return_value = [mock_pr]
+
+ prs = github_toolkit.get_pull_request_list()
+ expected_prs = [{"number": 1, "title": "Test PR"}]
+
+ assert prs == expected_prs, f"Expected {expected_prs}, but got {prs}"
+
+ @patch.object(Github, 'get_repo', return_value=MagicMock())
+ @patch.object(Auth.Token, '__init__', lambda self, *args, **kwargs: None)
+ def test_get_pull_request_code(monkeypatch):
+ github_toolkit = GithubToolkit("repo_name", "token")
+ mock_file = MagicMock()
+ mock_file.filename = "file1.py"
+ mock_file.patch = "code changes"
+ github_toolkit.repo.get_pull.return_value.get_files.return_value = [
+ mock_file
+ ]
+
+ files_changed = github_toolkit.get_pull_request_code(1)
+ expected_files = [{"filename": "file1.py", "patch": "code changes"}]
+
+ assert (
+ files_changed == expected_files
+ ), f"Expected {expected_files}, but got {files_changed}"
+
+ @patch.object(Github, 'get_repo', return_value=MagicMock())
+ @patch.object(Auth.Token, '__init__', lambda self, *args, **kwargs: None)
+ def test_get_pull_request_comments(monkeypatch):
+ github_toolkit = GithubToolkit("repo_name", "token")
+ mock_comment = MagicMock()
+ mock_comment.user.login = "user1"
+ mock_comment.body = "Test comment"
+ github_toolkit.repo.get_pull.return_value.get_comments.return_value = [
+ mock_comment
+ ]
+
+ comments = github_toolkit.get_pull_request_comments(1)
+ expected_comments = [{"user": "user1", "body": "Test comment"}]
+
+ assert (
+ comments == expected_comments
+ ), f"Expected {expected_comments}, but got {comments}"
+
+ @patch.object(Github, 'get_repo', return_value=MagicMock())
+ @patch.object(Auth.Token, '__init__', lambda self, *args, **kwargs: None)
+ def test_get_all_file_paths(monkeypatch):
+ github_toolkit = GithubToolkit("repo_name", "token")
+ mock_content = MagicMock()
+ mock_content.type = "file"
+ mock_content.path = "path/to/file.py"
+ github_toolkit.repo.get_contents.return_value = [mock_content]
+
+ files = github_toolkit.get_all_file_paths()
+ expected_files = ["path/to/file.py"]
+
+ assert (
+ files == expected_files
+ ), f"Expected {expected_files}, but got {files}"
diff --git a/uv.lock b/uv.lock
index b562a3e73..e0cbac7e1 100644
--- a/uv.lock
+++ b/uv.lock
@@ -534,7 +534,7 @@ wheels = [
[[package]]
name = "camel-ai"
-version = "0.2.36"
+version = "0.2.37"
source = { editable = "." }
dependencies = [
{ name = "colorama" },
@@ -934,8 +934,8 @@ requires-dist = [
{ name = "pydantic", specifier = ">=1.9,<2.10" },
{ name = "pydub", marker = "extra == 'all'", specifier = ">=0.25.1,<0.26" },
{ name = "pydub", marker = "extra == 'media-tools'", specifier = ">=0.25.1,<0.26" },
- { name = "pygithub", marker = "extra == 'all'", specifier = ">=2.3.0,<3" },
- { name = "pygithub", marker = "extra == 'communication-tools'", specifier = ">=2.3.0,<3" },
+ { name = "pygithub", marker = "extra == 'all'", specifier = ">=2.6.0,<3" },
+ { name = "pygithub", marker = "extra == 'communication-tools'", specifier = ">=2.6.0,<3" },
{ name = "pymilvus", marker = "extra == 'all'", specifier = ">=2.4.0,<3" },
{ name = "pymilvus", marker = "extra == 'rag'", specifier = ">=2.4.0,<3" },
{ name = "pymilvus", marker = "extra == 'storage'", specifier = ">=2.4.0,<3" },