🐫 CAMEL: The first and the best multi-agent framework. Finding the Scaling Law of Agents. https://www.camel-ai.org
Python agentai-societiesartificial-intelligencecommunicative-aicooperative-aideep-learninglarge-language-modelsmulti-agent-systemsnatural-language-processing
refactor: Wolfram Alpha and Github Toolkit (#2447)
Wendong-Fan87b7de5b9890
diff --git a/.github/ISSUE_TEMPLATE/bug_report.yml b/.github/ISSUE_TEMPLATE/bug_report.ymlindex 80376a662..cfdb3e63c 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.59+ placeholder: E.g., 0.2.60validations:required: truediff --git a/camel/__init__.py b/camel/__init__.pyindex 8859b718d..5c5362ab8 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.59'+__version__ = '0.2.60'__all__ = ['__version__',diff --git a/camel/toolkits/github_toolkit.py b/camel/toolkits/github_toolkit.pyindex 1c401f227..6c13e7844 100644--- a/camel/toolkits/github_toolkit.py+++ b/camel/toolkits/github_toolkit.py@@ -32,7 +32,6 @@ class GithubToolkit(BaseToolkit):specific issues, and creating pull requests in a GitHub repository.Args:- repo_name (str): The name of the GitHub repository.access_token (str, optional): The access token to authenticate withGitHub. If not provided, it will be obtained using the`get_github_access_token` method.@@ -41,7 +40,6 @@ class GithubToolkit(BaseToolkit):@dependencies_required('github')def __init__(self,- repo_name: str,access_token: Optional[str] = None,timeout: Optional[float] = None,) -> None:@@ -61,7 +59,6 @@ class GithubToolkit(BaseToolkit):access_token = self.get_github_access_token()self.github = Github(auth=Token(access_token))- self.repo = self.github.get_repo(repo_name)def get_github_access_token(self) -> str:r"""Retrieve the GitHub access token from environment variables.@@ -85,6 +82,7 @@ class GithubToolkit(BaseToolkit):def create_pull_request(self,+ repo_name: str,file_path: str,new_content: str,pr_title: str,@@ -98,6 +96,7 @@ class GithubToolkit(BaseToolkit):description contains information about the issue title and number.Args:+ repo_name (str): The name of the GitHub repository.file_path (str): The path of the file to be updated in therepository.new_content (str): The specified new content of the specified file.@@ -111,12 +110,13 @@ class GithubToolkit(BaseToolkit):str: A formatted report of whether the pull request was createdsuccessfully or not."""- sb = self.repo.get_branch(self.repo.default_branch)+ repo = self.github.get_repo(repo_name)+ default_branch = repo.get_branch(repo.default_branch)from github.GithubException import GithubExceptiontry:- self.repo.create_git_ref(- ref=f"refs/heads/{branch_name}", sha=sb.commit.sha+ repo.create_git_ref(+ ref=f"refs/heads/{branch_name}", sha=default_branch.commit.sha)except GithubException as e:if e.message == "Reference already exists":@@ -128,19 +128,19 @@ class GithubToolkit(BaseToolkit):else:raise- file = self.repo.get_contents(file_path)+ file = repo.get_contents(file_path)from github.ContentFile import ContentFileif isinstance(file, ContentFile):- self.repo.update_file(+ repo.update_file(file.path, body, new_content, file.sha, branch=branch_name)- pr = self.repo.create_pull(+ pr = repo.create_pull(title=pr_title,body=body,head=branch_name,- base=self.repo.default_branch,+ base=repo.default_branch,)if pr is not None:@@ -151,11 +151,12 @@ class GithubToolkit(BaseToolkit):raise ValueError("PRs with multiple files aren't supported yet.")def get_issue_list(- self, state: Literal["open", "closed", "all"] = "all"+ self, repo_name: str, state: Literal["open", "closed", "all"] = "all") -> List[Dict[str, object]]:r"""Retrieves all issues from the GitHub repository.Args:+ repo_name (str): The name of the GitHub repository.state (Literal["open", "closed", "all"]): The state of pullrequests to retrieve. (default: :obj: `all`)Options are:@@ -167,35 +168,39 @@ class GithubToolkit(BaseToolkit):List[Dict[str, object]]: A list of dictionaries where eachdictionary contains the issue number and title."""+ repo = self.github.get_repo(repo_name)issues_info = []- issues = self.repo.get_issues(state=state)+ issues = repo.get_issues(state=state)for issue in issues:issues_info.append({"number": issue.number, "title": issue.title})return issues_info- def get_issue_content(self, issue_number: int) -> str:+ def get_issue_content(self, repo_name: str, issue_number: int) -> str:r"""Retrieves the content of a specific issue by its number.Args:+ repo_name (str): The name of the GitHub repository.issue_number (int): The number of the issue to retrieve.Returns:str: issues content details."""try:- issue = self.repo.get_issue(number=issue_number)+ repo = self.github.get_repo(repo_name)+ issue = repo.get_issue(number=issue_number)return issue.bodyexcept Exception as e:return f"can't get Issue number {issue_number}: {e!s}"def get_pull_request_list(- self, state: Literal["open", "closed", "all"] = "all"+ self, repo_name: str, state: Literal["open", "closed", "all"] = "all") -> List[Dict[str, object]]:r"""Retrieves all pull requests from the GitHub repository.Args:+ repo_name (str): The name of the GitHub repository.state (Literal["open", "closed", "all"]): The state of pullrequests to retrieve. (default: :obj: `all`)Options are:@@ -207,18 +212,22 @@ class GithubToolkit(BaseToolkit):list: A list of dictionaries where each dictionary contains thepull request number and title."""+ repo = self.github.get_repo(repo_name)pull_requests_info = []- pull_requests = self.repo.get_pulls(state=state)+ pull_requests = repo.get_pulls(state=state)for pr in pull_requests:pull_requests_info.append({"number": pr.number, "title": pr.title})return pull_requests_info- def get_pull_request_code(self, pr_number: int) -> List[Dict[str, str]]:+ def get_pull_request_code(+ self, repo_name: str, pr_number: int+ ) -> List[Dict[str, str]]:r"""Retrieves the code changes of a specific pull request.Args:+ repo_name (str): The name of the GitHub repository.pr_number (int): The number of the pull request to retrieve.Returns:@@ -226,8 +235,9 @@ class GithubToolkit(BaseToolkit):contains the file name and the corresponding code changes(patch)."""+ repo = self.github.get_repo(repo_name)# Retrieve the specific pull request- pr = self.repo.get_pull(number=pr_number)+ pr = repo.get_pull(number=pr_number)# Collect the file changes from the pull requestfiles_changed = []@@ -244,19 +254,21 @@ class GithubToolkit(BaseToolkit):return files_changeddef get_pull_request_comments(- self, pr_number: int+ self, repo_name: str, pr_number: int) -> List[Dict[str, str]]:r"""Retrieves the comments from a specific pull request.Args:+ repo_name (str): The name of the GitHub repository.pr_number (int): The number of the pull request to retrieve.Returns:List[Dict[str, str]]: A list of dictionaries where each dictionarycontains the user ID and the comment body."""+ repo = self.github.get_repo(repo_name)# Retrieve the specific pull request- pr = self.repo.get_pull(number=pr_number)+ pr = repo.get_pull(number=pr_number)# Collect the comments from the pull requestcomments = []@@ -266,10 +278,11 @@ class GithubToolkit(BaseToolkit):return comments- def get_all_file_paths(self, path: str = "") -> List[str]:+ def get_all_file_paths(self, repo_name: str, path: str = "") -> List[str]:r"""Recursively retrieves all file paths in the GitHub repository.Args:+ repo_name (str): The name of the GitHub repository.path (str): The repository path to start the traversal from.empty string means starts from the root directory.(default: :obj: `""`)@@ -280,11 +293,13 @@ class GithubToolkit(BaseToolkit):"""from github.ContentFile import ContentFile+ repo = self.github.get_repo(repo_name)+files: List[str] = []# Retrieves all contents of the current directory- contents: Union[List[ContentFile], ContentFile] = (- self.repo.get_contents(path)+ contents: Union[List[ContentFile], ContentFile] = repo.get_contents(+ path)if isinstance(contents, ContentFile):@@ -299,10 +314,11 @@ class GithubToolkit(BaseToolkit):files.append(content.path)return files- def retrieve_file_content(self, file_path: str) -> str:+ def retrieve_file_content(self, repo_name: str, file_path: str) -> str:r"""Retrieves the content of a file from the GitHub repository.Args:+ repo_name (str): The name of the GitHub repository.file_path (str): The path of the file to retrieve.Returns:@@ -310,7 +326,9 @@ class GithubToolkit(BaseToolkit):"""from github.ContentFile import ContentFile- file_content = self.repo.get_contents(file_path)+ repo = self.github.get_repo(repo_name)++ file_content = repo.get_contents(file_path)if isinstance(file_content, ContentFile):return file_content.decoded_content.decode()else:diff --git a/camel/toolkits/wolfram_alpha_toolkit.py b/camel/toolkits/wolfram_alpha_toolkit.pyindex b171793eb..5d1a9795e 100644--- a/camel/toolkits/wolfram_alpha_toolkit.py+++ b/camel/toolkits/wolfram_alpha_toolkit.py@@ -13,7 +13,7 @@# ========= Copyright 2023-2024 @ CAMEL-AI.org. All Rights Reserved. =========import osimport xml.etree.ElementTree as ET-from typing import Any, Dict, List, Union+from typing import Any, Dict, Listimport requests@@ -37,21 +37,14 @@ class WolframAlphaToolkit(BaseToolkit):])@dependencies_required("wolframalpha")- def query_wolfram_alpha(- self, query: str, is_detailed: bool = False- ) -> Union[str, Dict[str, Any]]:- r"""Queries Wolfram|Alpha and returns the result.+ def query_wolfram_alpha(self, query: str) -> str:+ r"""Queries Wolfram|Alpha and returns the result as a simple answer.Args:query (str): The query to send to Wolfram Alpha.- is_detailed (bool): Whether to include additional details- including step by step information in the result.- (default: :obj:`False`)Returns:- Union[str, Dict[str, Any]]: The result from Wolfram Alpha.- Returns a string if `is_detailed` is False, otherwise returns- a dictionary with detailed information.+ str: The result from Wolfram Alpha as a simple answer."""import wolframalpha@@ -64,16 +57,45 @@ class WolframAlphaToolkit(BaseToolkit):except Exception as e:return f"Wolfram Alpha wasn't able to answer it. Error: {e}"- pased_result = self._parse_wolfram_result(res)+ parsed_result = self._parse_wolfram_result(res)+ return parsed_result["final_answer"]- if is_detailed:- step_info = self._get_wolframalpha_step_by_step_solution(- WOLFRAMALPHA_APP_ID, query- )- pased_result["steps"] = step_info- return pased_result+ @api_keys_required(+ [+ (None, "WOLFRAMALPHA_APP_ID"),+ ]+ )+ @dependencies_required("wolframalpha")+ def query_wolfram_alpha_step_by_step(self, query: str) -> Dict[str, Any]:+ r"""Queries Wolfram|Alpha and returns detailed results with+ step-by-step solution.++ Args:+ query (str): The query to send to Wolfram Alpha.++ Returns:+ Dict[str, Any]: A dictionary with detailed information including+ step-by-step solution.+ """+ import wolframalpha++ WOLFRAMALPHA_APP_ID = os.environ.get("WOLFRAMALPHA_APP_ID", "")++ try:+ client = wolframalpha.Client(WOLFRAMALPHA_APP_ID)+ res = client.query(query)++ except Exception as e:+ return {+ "error": f"Wolfram Alpha wasn't able to answer it. Error: {e}"+ }- return pased_result["final_answer"]+ parsed_result = self._parse_wolfram_result(res)+ step_info = self._get_wolframalpha_step_by_step_solution(+ WOLFRAMALPHA_APP_ID, query+ )+ parsed_result["steps"] = step_info+ return parsed_result@api_keys_required([@@ -234,5 +256,6 @@ class WolframAlphaToolkit(BaseToolkit):"""return [FunctionTool(self.query_wolfram_alpha),+ FunctionTool(self.query_wolfram_alpha_step_by_step),FunctionTool(self.query_wolfram_alpha_llm),]diff --git a/docs/conf.py b/docs/conf.pyindex d666b7b87..2aadf6260 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.59'+release = '0.2.60'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.mdindex 80ed8e232..8ca17b015 100644--- a/docs/key_modules/loaders.md+++ b/docs/key_modules/loaders.md@@ -357,14 +357,14 @@ print(response)``````markdown->>>Welcome to CAMEL’s documentation! — CAMEL 0.2.59 documentation+>>>Welcome to CAMEL’s documentation! — CAMEL 0.2.60 documentation===============[Skip to main content](https://docs.camel-ai.org/#main-content)Back to top Ctrl+K- [ CAMEL 0.2.59](https://docs.camel-ai.org/#)+ [ CAMEL 0.2.60](https://docs.camel-ai.org/#)Search Ctrl+Kdiff --git a/examples/toolkits/github_toolkit.py b/examples/toolkits/github_toolkit.pyindex 9098d66bb..491db1f3e 100644--- a/examples/toolkits/github_toolkit.py+++ b/examples/toolkits/github_toolkit.py@@ -14,10 +14,10 @@from camel.toolkits import GithubToolkit-gt = GithubToolkit(repo_name="camel-ai/camel")+gt = GithubToolkit()# Retrieve a list of all file paths within the camel GitHub repository-paths = gt.get_all_file_paths()+paths = gt.get_all_file_paths(repo_name="camel-ai/camel")print(paths)"""===============================================================================@@ -46,7 +46,9 @@ agents/base.py', 'camel/agents/chat_agent.py', 'camel/agents/critic_agent.py',"""# Retrieve the content of a specific file in the repository-content = gt.retrieve_file_content("camel/agents/chat_agent.py")+content = gt.retrieve_file_content(+ repo_name="camel-ai/camel", file_path="camel/agents/chat_agent.py"+)print(content[:1000])"""===============================================================================diff --git a/examples/toolkits/wolfram_alpha_toolkit.py b/examples/toolkits/wolfram_alpha_toolkit.pyindex a2e9942c7..8580d3754 100644--- a/examples/toolkits/wolfram_alpha_toolkit.py+++ b/examples/toolkits/wolfram_alpha_toolkit.py@@ -12,92 +12,125 @@# limitations under the License.# ========= Copyright 2023-2024 @ CAMEL-AI.org. All Rights Reserved. =========# ruff: noqa: RUF001+from camel.agents import ChatAgentfrom camel.models import ModelFactoryfrom camel.toolkits import WolframAlphaToolkitfrom camel.types import ModelPlatformType, ModelType+system_message = "You're a helpful assistant"+model = ModelFactory.create(model_platform=ModelPlatformType.DEFAULT,model_type=ModelType.DEFAULT,+ model_config_dict={"temperature": 0.0},)-res_simple = WolframAlphaToolkit().query_wolfram_alpha(- query="10 densest elemental metals", is_detailed=False+tools = [WolframAlphaToolkit().query_wolfram_alpha]++agent = ChatAgent(+ system_message=system_message,+ model=model,+ tools=tools,)-print(res_simple)+response = agent.step("What's 5 densest elemental metals")++print(response.msgs[0].content)+print("\nTool calls:")+print(response.info['tool_calls'])'''===============================================================================-1 | hassium | 41 g/cm^3 |-2 | meitnerium | 37.4 g/cm^3 |-3 | bohrium | 37.1 g/cm^3 |-4 | seaborgium | 35.3 g/cm^3 |-5 | darmstadtium | 34.8 g/cm^3 |-⋮ | | |+The five densest elemental metals are:++1. Hassium (Hs) - 41 g/cm³+2. Meitnerium (Mt) - 37.4 g/cm³+3. Bohrium (Bh) - 37.1 g/cm³+4. Seaborgium (Sg) - 35.3 g/cm³+5. Darmstadtium (Ds) - 34.8 g/cm³++Tool calls:+[ToolCallingRecord(tool_name='query_wolfram_alpha', args={'query': 'densest+elemental metals'}, result='1 | hassium | 41 g/cm^3 | \n2 | meitnerium | 37.4+g/cm^3 | \n3 | bohrium | 37.1 g/cm^3 | \n4 | seaborgium | 35.3 g/cm^3 | \n5 |+darmstadtium | 34.8 g/cm^3 |', tool_call_id='call_DNUzXQSQxAY3R71WMQXhKjBK')]==============================================================================='''-res_detailed = WolframAlphaToolkit().query_wolfram_alpha(- query="10 densest elemental metals", is_detailed=True+tools = [WolframAlphaToolkit().query_wolfram_alpha_step_by_step]++agent = ChatAgent(+ system_message=system_message,+ model=model,+ tools=tools,)-print(res_detailed)+response = agent.step("What's 5 densest elemental metals")++print(response.msgs[0].content)+print("\nTool calls:")+print(response.info['tool_calls'])'''===============================================================================-{'query': '10 densest elemental metals', 'pod_info': [{'title': 'Input-interpretation', 'description': '10 densest metallic elements | by mass-density', 'image_url': 'https://www6b3.wolframalpha.com/Calculate/MSP/-MSP80615372a2bchig48380000471fi5d51ii9552i?MSPStoreType=image/gif&s=16'},-{'title': 'Periodic table location', 'description': None, 'image_url':-'https://www6b3.wolframalpha.com/Calculate/MSP/-MSP80715372a2bchig483800001902583db73681b0?MSPStoreType=image/gif&s=16'},+The five densest elemental metals are:++1. **Hassium (Hs)** - 41 g/cm³+2. **Meitnerium (Mt)** - 37.4 g/cm³+3. **Bohrium (Bh)** - 37.1 g/cm³+4. **Seaborgium (Sg)** - 35.3 g/cm³+5. **Darmstadtium (Ds)** - 34.8 g/cm³++These values represent their densities at standard conditions.++Tool calls:+[ToolCallingRecord(tool_name='query_wolfram_alpha_step_by_step', args=+{'query': '5 densest elemental metals'}, result={'query': '5 densest elemental+metals', 'pod_info': [{'title': 'Input interpretation', 'description': '5+densest metallic elements | by mass density', 'image_url': 'https://www6b3.+wolframalpha.com/Calculate/MSP/MSP961i0eg636ce4a7a95000064bh6be1f77a45af?+MSPStoreType=image/gif&s=10'}, {'title': 'Periodic table location',+'description': None, 'image_url': 'https://www6b3.wolframalpha.com/Calculate/+MSP/MSP971i0eg636ce4a7a9500001668a66eh7ifgd6g?MSPStoreType=image/gif&s=10'},{'title': 'Images', 'description': None, 'image_url': 'https://www6b3.-wolframalpha.com/Calculate/MSP/MSP80815372a2bchig483800001dif7af61710hcc8?-MSPStoreType=image/gif&s=16'}, {'title': 'Basic elemental properties',-'description': 'atomic symbol | all | Bh | Db | Ds | Hs | Ir | Mt | Os | Rf |-Rg | Sg\natomic number | median | 106.5\n | highest | 111 (roentgenium)\n |-lowest | 76 (osmium)\n | distribution | \natomic mass | median | 269 u\n |-highest | 282 u (roentgenium)\n | lowest | 190.23 u (osmium)\n |-distribution | \nhalf-life | median | 78 min\n | highest | 13 h (rutherfordium)-\n | lowest | 4 min (darmstadtium)\n | distribution |', 'image_url': 'https://-www6b3.wolframalpha.com/Calculate/MSP/-MSP80915372a2bchig4838000011cc2fb989c538fa?MSPStoreType=image/gif&s=16'},-{'title': 'Result', 'description': '1 | hassium | 41 g/cm^3 | \n2 |-meitnerium | 37.4 g/cm^3 | \n3 | bohrium | 37.1 g/cm^3 | \n4 | seaborgium | 35.-3 g/cm^3 | \n5 | darmstadtium | 34.8 g/cm^3 | \n⋮ | | |', 'image_url':-'https://www6b3.wolframalpha.com/Calculate/MSP/-MSP81115372a2bchig4838000036fgd7gggf347gd7?MSPStoreType=image/gif&s=16'},-{'title': 'Thermodynamic properties', 'description': 'phase at STP | all |-solid\n(properties at standard conditions)', 'image_url': 'https://www6b3.-wolframalpha.com/Calculate/MSP/MSP81315372a2bchig483800001gaa02a7439934fd?-MSPStoreType=image/gif&s=16'}, {'title': 'Material properties', 'description':-'mass density | median | 32.1 g/cm^3\n | highest | 41 g/cm^3 (hassium)\n |-lowest | 22.56 g/cm^3 (iridium)\n | distribution | \n(properties at standard-conditions)', 'image_url': 'https://www6b3.wolframalpha.com/Calculate/MSP/-MSP81415372a2bchig48380000408d23ifc2b056f3?MSPStoreType=image/gif&s=16'},-{'title': 'Reactivity', 'description': 'valence | median | 6\n | highest | 7-(bohrium)\n | lowest | 4 (rutherfordium)\n | distribution |', 'image_url':+wolframalpha.com/Calculate/MSP/MSP981i0eg636ce4a7a95000025abi817gdd2964g?+MSPStoreType=image/gif&s=10'}, {'title': 'Basic elemental properties',+'description': '| atomic symbol | atomic number\nhassium | Hs |+108\nmeitnerium | Mt | 109\nbohrium | Bh | 107\nseaborgium | Sg |+106\ndarmstadtium | Ds | 110\n | atomic mass | half-life\nhassium | 269 u | 67+min\nmeitnerium | 277 u | 30 min\nbohrium | 270 u | 90 min\nseaborgium | 269+u | 120 min\ndarmstadtium | 281 u | 4 min', 'image_url': 'https://www6b3.+wolframalpha.com/Calculate/MSP/MSP991i0eg636ce4a7a9500003263452b10d0d8f7?+MSPStoreType=image/gif&s=10'}, {'title': 'Result', 'description': '1 |+hassium | 41 g/cm^3 | \n2 | meitnerium | 37.4 g/cm^3 | \n3 | bohrium | 37.1 g/+cm^3 | \n4 | seaborgium | 35.3 g/cm^3 | \n5 | darmstadtium | 34.8 g/cm^3 |',+'image_url': 'https://www6b3.wolframalpha.com/Calculate/MSP/+MSP1011i0eg636ce4a7a95000021433b3eei2283i7?MSPStoreType=image/gif&s=10'},+{'title': 'Material properties', 'description': 'mass density | median | 37.1+g/cm^3\n | highest | 41 g/cm^3 (hassium)\n | lowest | 34.8 g/cm^3+(darmstadtium)\n | distribution | \n(properties at standard conditions)',+'image_url': 'https://www6b3.wolframalpha.com/Calculate/MSP/+MSP1031i0eg636ce4a7a95000012h4aa1fg10h84eg?MSPStoreType=image/gif&s=10'},+{'title': 'Atomic properties', 'description': 'term symbol | all | ^3D_3 | ^4F_+(9/2) | ^5D_0 | ^5D_4 | ^6S_(5/2)\n(electronic ground state properties)',+'image_url': 'https://www6b3.wolframalpha.com/Calculate/MSP/+MSP1051i0eg636ce4a7a95000024dii0bd852f9bib?MSPStoreType=image/gif&s=10'},+{'title': 'Abundances', 'description': 'crust abundance | median | 0 mass%\n |+highest | 0 mass% (5 elements)\n | lowest | 0 mass% (5 elements)\nhuman+abundance | median | 0 mass%\n | highest | 0 mass% (5 elements)\n | lowest | 0+mass% (5 elements)', 'image_url': 'https://www6b3.wolframalpha.com/Calculate/+MSP/MSP1061i0eg636ce4a7a9500005iagh7h9413cc095?MSPStoreType=image/gif&s=10'},+{'title': 'Nuclear properties', 'description': 'half-life | median | 67+min\n | highest | 120 min (seaborgium)\n | lowest | 4 min (darmstadtium)\n |+distribution | \nspecific radioactivity | highest | 6.123×10^6 TBq/g+(darmstadtium)\n | lowest | 223871 TBq/g (seaborgium)\n | median | 446085 TBq/+g', 'image_url': 'https://www6b3.wolframalpha.com/Calculate/MSP/+MSP1081i0eg636ce4a7a9500001ae7307034bg8h9a?MSPStoreType=image/gif&s=10'},+{'title': 'Wikipedia page hits history', 'description': None, 'image_url':'https://www6b3.wolframalpha.com/Calculate/MSP/-MSP81615372a2bchig483800003ih6ci3c0fab279f?MSPStoreType=image/gif&s=16'},-{'title': 'Atomic properties', 'description': 'term symbol | all | ^2S_(1/2) |-^3D_3 | ^3F_2 | ^4F_(3/2) | ^4F_(9/2) | ^5D_0 | ^5D_4 | ^6S_(5/2)\n(electronic-ground state properties)', 'image_url': 'https://www6b3.wolframalpha.com/-Calculate/MSP/MSP81715372a2bchig48380000421b78e47ddc5de0?MSPStoreType=image/-gif&s=16'}, {'title': 'Abundances', 'description': 'crust abundance | median |-0 mass%\n | highest | 1.8×10^-7 mass% (osmium)\n | lowest | 0 mass% (8-elements)\nhuman abundance | median | 0 mass%\n | highest | 0 mass% (8-elements)\n | lowest | 0 mass% (8 elements)', 'image_url': 'https://www6b3.-wolframalpha.com/Calculate/MSP/MSP81815372a2bchig48380000399cbba92d566dac?-MSPStoreType=image/gif&s=16'}, {'title': 'Nuclear properties', 'description':-'half-life | median | 78 min\n | highest | 13 h (rutherfordium)\n | lowest | 4-min (darmstadtium)\n | distribution | \nspecific radioactivity | highest | 6.-123×10^6 TBq/g (darmstadtium)\n | lowest | 33169 TBq/g (rutherfordium)\n |-median | 366018 TBq/g\n | distribution |', 'image_url': 'https://www6b3.-wolframalpha.com/Calculate/MSP/MSP82015372a2bchig4838000023ga94gh9ihhhefb?-MSPStoreType=image/gif&s=16'}], 'final_answer': '1 | hassium | 41 g/cm^3 |-\n2 | meitnerium | 37.4 g/cm^3 | \n3 | bohrium | 37.1 g/cm^3 | \n4 |-seaborgium | 35.3 g/cm^3 | \n5 | darmstadtium | 34.8 g/cm^3 | \n⋮ | | |',-'steps': {}}+MSP1101i0eg636ce4a7a9500003aeef8d2fi6ih413?MSPStoreType=image/gif&s=10'}],+'final_answer': '1 | hassium | 41 g/cm^3 | \n2 | meitnerium | 37.4 g/cm^3 |+\n3 | bohrium | 37.1 g/cm^3 | \n4 | seaborgium | 35.3 g/cm^3 | \n5 |+darmstadtium | 34.8 g/cm^3 |', 'steps': {}},+tool_call_id='call_e6gApIh8ohCARb4fb9WDxEsq')]==============================================================================='''diff --git a/pyproject.toml b/pyproject.tomlindex c09f1590b..4646121f5 100644--- a/pyproject.toml+++ b/pyproject.toml@@ -4,7 +4,7 @@ build-backend = "hatchling.build"[project]name = "camel-ai"-version = "0.2.59"+version = "0.2.60"description = "Communicative Agents for AI Society Study"authors = [{ name = "CAMEL-AI.org" }]requires-python = ">=3.10,<3.13"diff --git a/test/toolkits/test_github_toolkit.py b/test/toolkits/test_github_toolkit.pyindex 43c115b18..27e7efb22 100644--- a/test/toolkits/test_github_toolkit.py+++ b/test/toolkits/test_github_toolkit.py@@ -85,7 +85,7 @@ def test_init(mock_github):mock_repo = MagicMock()mock_github.return_value.get_repo.return_value = mock_repo# Create toolkit with mock auth- github_toolkit = GithubToolkit("repo_name", "token")+ github_toolkit = GithubToolkit(access_token="token")assert github_toolkit is not None, "Failed to initialize GithubToolkit"@@ -97,7 +97,7 @@ def test_get_tools(mock_github):mock_repo = MagicMock()mock_github.return_value.get_repo.return_value = mock_repo# Create toolkit with mock auth- github_toolkit = GithubToolkit("repo_name", "token")+ github_toolkit = GithubToolkit(access_token="token")tools = github_toolkit.get_tools()assert isinstance(tools, list), "get_tools should return a list"assert len(tools) > 0, "get_tools should return a non-empty list"@@ -111,7 +111,7 @@ def test_create_pull_request(mock_github):mock_repo = MagicMock()mock_github.return_value.get_repo.return_value = mock_repo# Create toolkit with mock auth- github_toolkit = GithubToolkit("repo_name", "token")+ github_toolkit = GithubToolkit(access_token="token")# Setup branchmock_branch = MagicMock()mock_branch.commit.sha = "test_sha"@@ -127,11 +127,13 @@ def test_create_pull_request(mock_github):# Create a simplified version of create_pull_request that# skips the isinstance checkdef simplified_create_pull_request(- self, file_path, new_content, pr_title, body, branch_name+ self, repo_name, file_path, new_content, pr_title, body, branch_name):+ # Get the repo using the repo_name parameter+ repo = self.github.get_repo(repo_name)# Skip the isinstance check and just update the file- file = self.repo.get_contents(file_path)- self.repo.update_file(+ file = repo.get_contents(file_path)+ repo.update_file(file.path, body, new_content, file.sha, branch=branch_name)return f"Title: {pr_title}\nBody: {body}\n"@@ -149,6 +151,7 @@ def test_create_pull_request(mock_github):body = "Fixes #1"pr = github_toolkit.create_pull_request(+ repo_name="repo_name",file_path="path/to/file",branch_name="branch_name",new_content="This is the content of the file",@@ -171,7 +174,7 @@ def test_get_all_issues(mock_github):mock_repo = MagicMock()mock_github.return_value.get_repo.return_value = mock_repo# Create toolkit with mock auth- github_toolkit = GithubToolkit("repo_name", "token")+ github_toolkit = GithubToolkit(access_token="token")# Setup issuesmock_issue = MagicMock()mock_issue.number = 1@@ -183,7 +186,7 @@ def test_get_all_issues(mock_github):'get_issue_list',return_value=[{"number": 1, "title": "Test Issue"}],):- issues = github_toolkit.get_issue_list()+ issues = github_toolkit.get_issue_list(repo_name="repo_name")expected_issues = [{"number": 1, "title": "Test Issue"}]assert (issues == expected_issues@@ -198,7 +201,7 @@ def test_get_issue_content(mock_github):mock_repo = MagicMock()mock_github.return_value.get_repo.return_value = mock_repo# Create toolkit with mock auth- github_toolkit = GithubToolkit("repo_name", "token")+ github_toolkit = GithubToolkit(access_token="token")# Setup issuemock_issue = MagicMock()mock_issue.body = "Issue content"@@ -207,7 +210,9 @@ def test_get_issue_content(mock_github):with patch.object(github_toolkit, 'get_issue_content', return_value="Issue content"):- content = github_toolkit.get_issue_content(1)+ content = github_toolkit.get_issue_content(+ repo_name="repo_name", issue_number=1+ )expected_content = "Issue content"assert (content == expected_content@@ -222,7 +227,7 @@ def test_get_all_pull_requests(mock_github):mock_repo = MagicMock()mock_github.return_value.get_repo.return_value = mock_repo# Create toolkit with mock auth- github_toolkit = GithubToolkit("repo_name", "token")+ github_toolkit = GithubToolkit(access_token="token")# Setup PRsmock_pr = MagicMock()mock_pr.number = 1@@ -234,7 +239,7 @@ def test_get_all_pull_requests(mock_github):'get_pull_request_list',return_value=[{"number": 1, "title": "Test PR"}],):- prs = github_toolkit.get_pull_request_list()+ prs = github_toolkit.get_pull_request_list(repo_name="repo_name")expected_prs = [{"number": 1, "title": "Test PR"}]assert prs == expected_prs, f"Expected {expected_prs}, got {prs}"@@ -247,7 +252,7 @@ def test_get_pull_request_code(mock_github):mock_repo = MagicMock()mock_github.return_value.get_repo.return_value = mock_repo# Create toolkit with mock auth- github_toolkit = GithubToolkit("repo_name", "token")+ github_toolkit = GithubToolkit(access_token="token")# Setup PR filesmock_file = MagicMock()mock_file.filename = "file1.py"@@ -261,7 +266,9 @@ def test_get_pull_request_code(mock_github):'get_pull_request_code',return_value=[{"filename": "file1.py", "patch": "code changes"}],):- files_changed = github_toolkit.get_pull_request_code(1)+ files_changed = github_toolkit.get_pull_request_code(+ repo_name="repo_name", pr_number=1+ )expected_files = [{"filename": "file1.py", "patch": "code changes"}]assert (files_changed == expected_files@@ -276,7 +283,7 @@ def test_get_pull_request_comments(mock_github):mock_repo = MagicMock()mock_github.return_value.get_repo.return_value = mock_repo# Create toolkit with mock auth- github_toolkit = GithubToolkit("repo_name", "token")+ github_toolkit = GithubToolkit(access_token="token")# Setup PR commentsmock_user = MagicMock()mock_user.login = "user1"@@ -292,7 +299,9 @@ def test_get_pull_request_comments(mock_github):'get_pull_request_comments',return_value=[{"user": "user1", "body": "Test comment"}],):- comments = github_toolkit.get_pull_request_comments(1)+ comments = github_toolkit.get_pull_request_comments(+ repo_name="repo_name", pr_number=1+ )expected_comments = [{"user": "user1", "body": "Test comment"}]assert (comments == expected_comments@@ -307,7 +316,7 @@ def test_get_all_file_paths(mock_github):mock_repo = MagicMock()mock_github.return_value.get_repo.return_value = mock_repo# Create toolkit with mock auth- github_toolkit = GithubToolkit("repo_name", "token")+ github_toolkit = GithubToolkit(access_token="token")# Setup contentcontent_file = ContentFile(path="path/to/file.py", type="file")mock_repo.get_contents.return_value = [content_file]@@ -315,7 +324,7 @@ def test_get_all_file_paths(mock_github):with patch.object(github_toolkit, 'get_all_file_paths', return_value=["path/to/file.py"]):- files = github_toolkit.get_all_file_paths()+ files = github_toolkit.get_all_file_paths(repo_name="repo_name")expected_files = ["path/to/file.py"]assert (files == expected_filesdiff --git a/test/toolkits/test_wolframalpha_toolkit.py b/test/toolkits/test_wolframalpha_toolkit.pyindex 346d715e4..d1ffbec96 100644--- a/test/toolkits/test_wolframalpha_toolkit.py+++ b/test/toolkits/test_wolframalpha_toolkit.py@@ -29,6 +29,44 @@ def test_query_wolfram_alpha(mock_get_env, mock_client, mock_requests_get):{'@title': 'Limit','subpod': {'plaintext': 'lim_(x->0) (sin^2(x))/x = 0'},+ '@primary': 'true',+ },+ {+ '@title': 'Plot',+ 'subpod': {'plaintext': None},+ },+ ],+ }[key]++ mock_instance = MagicMock()+ mock_instance.query.return_value = mock_res+ mock_client.return_value = mock_instance++ result = WolframAlphaToolkit().query_wolfram_alpha(+ "calculate limit of sinx^2/x"+ )++ expected_output = "lim_(x->0) (sin^2(x))/x = 0"++ assert result == expected_output+++@patch('requests.get')+@patch('wolframalpha.Client')+@patch('os.environ.get')+def test_query_wolfram_alpha_step_by_step(+ mock_get_env, mock_client, mock_requests_get+):+ mock_get_env.return_value = 'FAKE_APP_ID'++ mock_res = MagicMock()+ mock_res.get.side_effect = lambda key, default: {+ '@inputstring': 'calculate limit of sinx^2/x',+ 'pod': [+ {+ '@title': 'Limit',+ 'subpod': {'plaintext': 'lim_(x->0) (sin^2(x))/x = 0'},+ '@primary': 'true',},{'@title': 'Plot',@@ -44,8 +82,9 @@ def test_query_wolfram_alpha(mock_get_env, mock_client, mock_requests_get):mock_requests_get.return_value = MagicMock(status_code=200)mock_requests_get.return_value.text = """<queryresult success="true" error="false">- <pod title="Limit">+ <pod title="Results"><subpod>+ <stepbystepcontenttype>SBSStep</stepbystepcontenttype><plaintext>lim_(x->0) (sin^2(x))/x = 0</plaintext></subpod></pod>@@ -57,8 +96,8 @@ def test_query_wolfram_alpha(mock_get_env, mock_client, mock_requests_get):</queryresult>"""- result = WolframAlphaToolkit().query_wolfram_alpha(- "calculate limit of sinx^2/x", True+ result = WolframAlphaToolkit().query_wolfram_alpha_step_by_step(+ "calculate limit of sinx^2/x")expected_output = {@@ -75,8 +114,8 @@ def test_query_wolfram_alpha(mock_get_env, mock_client, mock_requests_get):"image_url": '',},],- "final_answer": None,- "steps": {},+ "final_answer": "lim_(x->0) (sin^2(x))/x = 0",+ "steps": {"step1": "lim_(x->0) (sin^2(x))/x = 0"},}assert result == expected_outputdiff --git a/uv.lock b/uv.lockindex d22015d02..efd8feddc 100644--- a/uv.lock+++ b/uv.lock@@ -556,7 +556,7 @@ wheels = [[[package]]name = "camel-ai"-version = "0.2.59"+version = "0.2.60"source = { editable = "." }dependencies = [{ name = "colorama" },