🐫 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
chore: minor fix for aci cookbook and wolframaplha integration (#2426)
Wendong-Fanee6e3a1e8e66
diff --git a/camel/toolkits/wolfram_alpha_toolkit.py b/camel/toolkits/wolfram_alpha_toolkit.pyindex 3b5b93670..afa57f32c 100644--- a/camel/toolkits/wolfram_alpha_toolkit.py+++ b/camel/toolkits/wolfram_alpha_toolkit.py@@ -81,7 +81,8 @@ class WolframAlphaToolkit(BaseToolkit):])def query_wolfram_llm(self, query: str) -> str:- r"""Queries Wolfram|Alpha LLM API and returns the result.+ r"""Sends a query to the Wolfram|Alpha API optimized for language+ model usage.Args:query (str): The query to send to Wolfram Alpha LLM.diff --git a/docs/cookbooks/advanced_features/agents_with_tools_from_ACI.ipynb b/docs/cookbooks/advanced_features/agents_with_tools_from_ACI.ipynbindex e37ce96e6..903eb5532 100644--- a/docs/cookbooks/advanced_features/agents_with_tools_from_ACI.ipynb+++ b/docs/cookbooks/advanced_features/agents_with_tools_from_ACI.ipynb@@ -1,194 +1,269 @@{- "cells": [- {- "cell_type": "markdown",- "metadata": {},- "source": [- "# Using Tools from ACI"- ]- },- {- "cell_type": "markdown",- "metadata": {},- "source": [- "[ACI.dev](https://github.com/aipotheosis-labs/aci) is the open source platform that connects your AI agents to 600+ tool integrations. Integrate [ACI.dev](https://www.aci.dev/docs/introduction/overview) with CAMEL agents to let them seamlessly interact with these external apps."- ]- },- {- "cell_type": "markdown",- "metadata": {},- "source": [- "\n",- "⭐ <i>Star us on [*Github*](https://github.com/camel-ai/camel), join our [*Discord*](https://discord.camel-ai.org) or follow our [*X*](https://x.com/camelaiorg)"- ]- },- {- "cell_type": "markdown",- "metadata": {},- "source": [- "*Goal: Star a repository on GitHub with natural language & CAMEL Agent*"- ]- },- {- "cell_type": "markdown",- "metadata": {},- "source": [- "### Install Packages & Connect a Tool"- ]- },- {- "cell_type": "markdown",- "metadata": {},- "source": [- "Integrate ACI with CAMEL agents to let them seamlessly interact with external apps. "- ]- },- {- "cell_type": "markdown",- "metadata": {},- "source": [- "Ensure you have the necessary packages installed and connect your GitHub account to allow your CAMEL-AI agents to utilize GitHub functionalities on [*ACI.dev*](https://platform.aci.dev/apps)."- ]- },- {- "cell_type": "code",- "execution_count": null,- "metadata": {},- "outputs": [],- "source": [- "# Run command\n",- "%pip install \"camel-ai[all]\"\n",- "%pip install openai"- ]- },- {- "cell_type": "markdown",- "metadata": {},- "source": [- "### Prepare your environment by initializing necessary imports from CAMEL."- ]- },- {- "cell_type": "code",- "execution_count": 2,- "metadata": {},- "outputs": [],- "source": [- "from camel.agents import ChatAgent\n",- "from camel.models import ModelFactory\n",- "from camel.toolkits import ACIToolkit\n",- "from camel.types import ModelPlatformType, ModelType"- ]- },- {- "cell_type": "markdown",- "metadata": {},- "source": [- "### Provide the API key and the LINKED_ACCOUNT_OWNER from [*ACI.dev*](https://platform.aci.dev/apps) to the SDK."- ]- },- {- "cell_type": "code",- "execution_count": 3,- "metadata": {},- "outputs": [],- "source": [- "import os\n",- "from getpass import getpass\n",- "\n",- "# Prompt for the API key securely\n",- "openai_api_key = getpass('Enter your API key: ')\n",- "os.environ[\"OPENAI_API_KEY\"] = openai_api_key\n",- "# Prompt for the ACI key securely\n",- "aci_api_key = getpass('Enter your ACI API key: ')\n",- "os.environ[\"ACI_API_KEY\"] = aci_api_key\n",- "# Prompt for your linked account owner id securely\n",- "linked_account_owner_id = getpass('Enter your linked account owner id: ')\n",- "os.environ[\"LINKED_ACCOUNT_OWNER\"] = linked_account_owner_id"- ]- },- {- "cell_type": "markdown",- "metadata": {},- "source": [- "### Let’s run CAMEL agents with tools from ACI!"- ]- },- {- "cell_type": "code",- "execution_count": 4,- "metadata": {},- "outputs": [],- "source": [- "# Get the value of the environment variable \"LINKED_ACCOUNT_OWNER\"\n",- "LINKED_ACCOUNT_OWNER = os.getenv(\"LINKED_ACCOUNT_OWNER\")\n",- "\n",- "# Check if the environment variable was set\n",- "if LINKED_ACCOUNT_OWNER is None:\n",- " raise ValueError(\"LINKED_ACCOUNT_owner environment variable is not set.\")"- ]- },- {- "cell_type": "code",- "execution_count": null,- "metadata": {},- "outputs": [],- "source": [- "# Initialize ACI Toolkit with GitHub integration\n",- "aci_toolkit = ACIToolkit(linked_account_owner_id=LINKED_ACCOUNT_OWNER)\n",- "\n",- "# Create default model instance\n",- "model = ModelFactory.create(\n",- " model_platform=ModelPlatformType.DEFAULT,\n",- " model_type=ModelType.DEFAULT,\n",- ")\n",- "\n",- "# Set up chat agent with GitHub tools\n",- "chat_agent = ChatAgent(\n",- " model=model,\n",- " tools=aci_toolkit.get_tools(), # GitHub tools enabled\n",- ")"- ]- },- {- "cell_type": "code",- "execution_count": 6,- "metadata": {},- "outputs": [- {- "name": "stdout",- "output_type": "stream",- "text": [- "msgs=[BaseMessage(role_name='assistant', role_type=<RoleType.ASSISTANT: 'assistant'>, meta_dict={}, content='The repository **camel-ai/camel** has been successfully starred!', video_bytes=None, image_list=None, image_detail='auto', video_detail='low', parsed=None)] terminated=False info={'id': 'chatcmpl-BXS3BEiBjdRUJx2Ucu5ZdRadsE7s7', 'usage': {'prompt_tokens': 7713, 'completion_tokens': 41, 'total_tokens': 7754}, 'termination_reasons': ['stop'], 'num_tokens': 71, 'tool_calls': [ToolCallingRecord(tool_name='GITHUB__STAR_REPOSITORY', args={'path': {'repo': 'camel', 'owner': 'camel-ai'}}, result={'success': True, 'data': {}}, tool_call_id='call_tW60m9BWrXGmRMd5AbwASRdx')], 'external_tool_call_requests': None}\n"- ]+ "cells": [+ {+ "cell_type": "markdown",+ "metadata": {+ "id": "y5ra1tKcXxt9"+ },+ "source": [+ "# Using Tools from ACI"+ ]+ },+ {+ "cell_type": "markdown",+ "source": [+ "You can also check this cookbook in colab [here](https://colab.research.google.com/drive/1vMdwL4MZdWk8O8vFwc9ROuC1KtynFfSi?usp=sharing)"+ ],+ "metadata": {+ "id": "7l6fBprLYBmw"+ }+ },+ {+ "cell_type": "markdown",+ "metadata": {+ "id": "9Tz2K7D6Xxt-"+ },+ "source": [+ "[ACI.dev](https://github.com/aipotheosis-labs/aci) is the open source platform that connects your AI agents to 600+ tool integrations. Integrate [ACI.dev](https://www.aci.dev/docs/introduction/overview) with CAMEL agents to let them seamlessly interact with these external apps."+ ]+ },+ {+ "cell_type": "markdown",+ "metadata": {+ "id": "Rp5aGsG0Xxt-"+ },+ "source": [+ "\n",+ "⭐ <i>Star us on [*Github*](https://github.com/camel-ai/camel), join our [*Discord*](https://discord.camel-ai.org) or follow our [*X*](https://x.com/camelaiorg)"+ ]+ },+ {+ "cell_type": "markdown",+ "metadata": {+ "id": "dMB-ePtYXxt_"+ },+ "source": [+ "*Goal: Star a repository on GitHub with natural language & CAMEL Agent*"+ ]+ },+ {+ "cell_type": "markdown",+ "metadata": {+ "id": "AxObRHzdXxt_"+ },+ "source": [+ "### Install Packages & Connect a Tool"+ ]+ },+ {+ "cell_type": "markdown",+ "metadata": {+ "id": "Nys9izCgXxt_"+ },+ "source": [+ "Integrate ACI with CAMEL agents to let them seamlessly interact with external apps."+ ]+ },+ {+ "cell_type": "markdown",+ "metadata": {+ "id": "Nw-ruYT3XxuA"+ },+ "source": [+ "Ensure you have the necessary packages installed and connect your GitHub account to allow your CAMEL-AI agents to utilize GitHub functionalities on [*ACI.dev*](https://platform.aci.dev/apps)."+ ]+ },+ {+ "cell_type": "code",+ "execution_count": null,+ "metadata": {+ "id": "Vbzhv9tRXxuA"+ },+ "outputs": [],+ "source": [+ "# Run command\n",+ "%pip install \"camel-ai[all]==0.2.59\""+ ]+ },+ {+ "cell_type": "markdown",+ "metadata": {+ "id": "kSdmyLrZXxuB"+ },+ "source": [+ "### Prepare your environment by initializing necessary imports from CAMEL."+ ]+ },+ {+ "cell_type": "code",+ "execution_count": null,+ "metadata": {+ "id": "aQIxupKSXxuB"+ },+ "outputs": [],+ "source": [+ "from camel.agents import ChatAgent\n",+ "from camel.models import ModelFactory\n",+ "from camel.toolkits import ACIToolkit\n",+ "from camel.types import ModelPlatformType, ModelType"+ ]+ },+ {+ "cell_type": "markdown",+ "metadata": {+ "id": "JaBbWyEpXxuB"+ },+ "source": [+ "### Provide the API key and the LINKED_ACCOUNT_OWNER from [*ACI.dev*](https://platform.aci.dev/apps) to the SDK."+ ]+ },+ {+ "cell_type": "code",+ "execution_count": null,+ "metadata": {+ "id": "fAhEfnlwXxuB"+ },+ "outputs": [],+ "source": [+ "import os\n",+ "from getpass import getpass\n",+ "\n",+ "# Prompt for the API key securely\n",+ "openai_api_key = getpass('Enter your API key: ')\n",+ "os.environ[\"OPENAI_API_KEY\"] = openai_api_key\n",+ "# Prompt for the ACI key securely\n",+ "aci_api_key = getpass('Enter your ACI API key: ')\n",+ "os.environ[\"ACI_API_KEY\"] = aci_api_key\n",+ "# Prompt for your linked account owner id securely\n",+ "linked_account_owner_id = getpass('Enter your linked account owner id: ')\n",+ "os.environ[\"LINKED_ACCOUNT_OWNER\"] = linked_account_owner_id"+ ]+ },+ {+ "cell_type": "markdown",+ "metadata": {+ "id": "xSAU5mkpXxuC"+ },+ "source": [+ "### Let’s run CAMEL agents with tools from ACI!"+ ]+ },+ {+ "cell_type": "code",+ "execution_count": null,+ "metadata": {+ "id": "4ZkkAvqmXxuC"+ },+ "outputs": [],+ "source": [+ "# Get the value of the environment variable \"LINKED_ACCOUNT_OWNER\"\n",+ "LINKED_ACCOUNT_OWNER = os.getenv(\"LINKED_ACCOUNT_OWNER\")\n",+ "\n",+ "# Check if the environment variable was set\n",+ "if LINKED_ACCOUNT_OWNER is None:\n",+ " raise ValueError(\"LINKED_ACCOUNT_owner environment variable is not set.\")"+ ]+ },+ {+ "cell_type": "code",+ "execution_count": null,+ "metadata": {+ "id": "ONtulpJaXxuC"+ },+ "outputs": [],+ "source": [+ "# Initialize ACI Toolkit with GitHub integration\n",+ "aci_toolkit = ACIToolkit(linked_account_owner_id=LINKED_ACCOUNT_OWNER)\n",+ "\n",+ "# Create default model instance\n",+ "model = ModelFactory.create(\n",+ " model_platform=ModelPlatformType.DEFAULT,\n",+ " model_type=ModelType.DEFAULT,\n",+ ")\n",+ "\n",+ "# Set up chat agent with GitHub tools\n",+ "chat_agent = ChatAgent(\n",+ " model=model,\n",+ " tools=aci_toolkit.get_tools(), # GitHub tools enabled\n",+ ")"+ ]+ },+ {+ "cell_type": "code",+ "execution_count": null,+ "metadata": {+ "id": "SQZTOcdTXxuC",+ "outputId": "01df4d08-7f6d-4d82-aef3-2ac8ec77a997"+ },+ "outputs": [+ {+ "name": "stdout",+ "output_type": "stream",+ "text": [+ "msgs=[BaseMessage(role_name='assistant', role_type=<RoleType.ASSISTANT: 'assistant'>, meta_dict={}, content='The repository **camel-ai/camel** has been successfully starred!', video_bytes=None, image_list=None, image_detail='auto', video_detail='low', parsed=None)] terminated=False info={'id': 'chatcmpl-BXS3BEiBjdRUJx2Ucu5ZdRadsE7s7', 'usage': {'prompt_tokens': 7713, 'completion_tokens': 41, 'total_tokens': 7754}, 'termination_reasons': ['stop'], 'num_tokens': 71, 'tool_calls': [ToolCallingRecord(tool_name='GITHUB__STAR_REPOSITORY', args={'path': {'repo': 'camel', 'owner': 'camel-ai'}}, result={'success': True, 'data': {}}, tool_call_id='call_tW60m9BWrXGmRMd5AbwASRdx')], 'external_tool_call_requests': None}\n"+ ]+ }+ ],+ "source": [+ "# Execute GitHub star command\n",+ "response = chat_agent.step(\"star the repo camel-ai/camel\")\n",+ "print(response)"+ ]+ },+ {+ "cell_type": "markdown",+ "source": [+ "That's everything: Got questions about 🐫 CAMEL-AI? Join us on [Discord](https://discord.camel-ai.org)! Whether you want to share feedback, explore the latest in multi-agent systems, get support, or connect with others on exciting projects, we’d love to have you in the community! 🤝\n",+ "\n",+ "Check out some of our other work:\n",+ "\n",+ "1. 🐫 Creating Your First CAMEL Agent [free Colab](https://docs.camel-ai.org/cookbooks/create_your_first_agent.html)\n",+ "\n",+ "2. Graph RAG Cookbook [free Colab](https://colab.research.google.com/drive/1uZKQSuu0qW6ukkuSv9TukLB9bVaS1H0U?usp=sharing)\n",+ "\n",+ "3. 🧑⚖️ Create A Hackathon Judge Committee with Workforce [free Colab](https://colab.research.google.com/drive/18ajYUMfwDx3WyrjHow3EvUMpKQDcrLtr?usp=sharing)\n",+ "\n",+ "4. 🔥 3 ways to ingest data from websites with Firecrawl & CAMEL [free Colab](https://colab.research.google.com/drive/1lOmM3VmgR1hLwDKdeLGFve_75RFW0R9I?usp=sharing)\n",+ "\n",+ "5. 🦥 Agentic SFT Data Generation with CAMEL and Mistral Models, Fine-Tuned with Unsloth [free Colab](https://colab.research.google.com/drive/1lYgArBw7ARVPSpdwgKLYnp_NEXiNDOd-?usp=sharingg)\n",+ "\n",+ "Thanks from everyone at 🐫 CAMEL-AI\n",+ "\n",+ "\n",+ "<div class=\"align-center\">\n",+ " <a href=\"https://www.camel-ai.org/\"><img src=\"https://i.postimg.cc/KzQ5rfBC/button.png\"width=\"150\"></a>\n",+ " <a href=\"https://discord.camel-ai.org\"><img src=\"https://i.postimg.cc/L4wPdG9N/join-2.png\" width=\"150\"></a></a>\n",+ " \n",+ "⭐ <i>Star us on [*Github*](https://github.com/camel-ai/camel), join our [*Discord*](https://discord.camel-ai.org) or follow our [*X*](https://x.com/camelaiorg)\n",+ "</div>\n"+ ],+ "metadata": {+ "id": "s6Det-fcMb9A"+ }+ }+ ],+ "metadata": {+ "kernelspec": {+ "display_name": "ai_agent_py11",+ "language": "python",+ "name": "python3"+ },+ "language_info": {+ "codemirror_mode": {+ "name": "ipython",+ "version": 3+ },+ "file_extension": ".py",+ "mimetype": "text/x-python",+ "name": "python",+ "nbconvert_exporter": "python",+ "pygments_lexer": "ipython3",+ "version": "3.11.11"+ },+ "colab": {+ "provenance": []}- ],- "source": [- "# Execute GitHub star command\n",- "response = chat_agent.step(\"star the repo camel-ai/camel\")\n",- "print(response)"- ]- }- ],- "metadata": {- "kernelspec": {- "display_name": "ai_agent_py11",- "language": "python",- "name": "python3"},- "language_info": {- "codemirror_mode": {- "name": "ipython",- "version": 3- },- "file_extension": ".py",- "mimetype": "text/x-python",- "name": "python",- "nbconvert_exporter": "python",- "pygments_lexer": "ipython3",- "version": "3.11.11"- }- },- "nbformat": 4,- "nbformat_minor": 2-}+ "nbformat": 4,+ "nbformat_minor": 0+}\ No newline at end of filediff --git a/examples/toolkits/wolfram_alpha_toolkit.py b/examples/toolkits/wolfram_alpha_toolkit.pyindex 8ed7f7c3d..6cce398e8 100644--- a/examples/toolkits/wolfram_alpha_toolkit.py+++ b/examples/toolkits/wolfram_alpha_toolkit.py@@ -22,60 +22,46 @@ model = ModelFactory.create()res_simple = WolframAlphaToolkit().query_wolfram_alpha(- query="solve 3x-7=11", is_detailed=False+ query="10 densest elemental metals", is_detailed=False)print(res_simple)'''===============================================================================-x = 6+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 |+⋮ | | |==============================================================================='''res_detailed = WolframAlphaToolkit().query_wolfram_alpha(- query="solve 3x-7=11", is_detailed=True+ query="10 densest elemental metals", is_detailed=True)print(res_detailed)'''===============================================================================-{'query': 'solve 3x-7=11', 'pod_info': [{'title': 'Input interpretation',-'description': 'solve 3 x - 7 = 11', 'image_url': 'https://www6b3.wolframalpha.-com/Calculate/MSP/MSP37741a3dc67f338579ff00003fih94dg39300iaf?-MSPStoreType=image/gif&s=18'}, {'title': 'Result', 'description': 'x = 6',-'image_url': 'https://www6b3.wolframalpha.com/Calculate/MSP/-MSP37751a3dc67f338579ff00001dg4gbdcd0f10i3f?MSPStoreType=image/gif&s=18'},-{'title': 'Plot', 'description': None, 'image_url': 'https://www6b3.-wolframalpha.com/Calculate/MSP/MSP37761a3dc67f338579ff0000374484g95bh3ah3e?-MSPStoreType=image/gif&s=18'}, {'title': 'Number line', 'description': None,-'image_url': 'https://www6b3.wolframalpha.com/Calculate/MSP/-MSP37771a3dc67f338579ff00005573c3a87ahg8dbc?MSPStoreType=image/gif&s=18'}],-'final_answer': 'x = 6', 'steps': {'step1': 'Isolate terms with x to the left-hand side.\nAdd 7 to both sides:\n3 x + (7 - 7) = 7 + 11', 'step2': 'Look for-the difference of two identical terms.\n7 - 7 = 0:\n3 x = 11 + 7', 'step3':-'Evaluate 11 + 7.\n11 + 7 = 18:\n3 x = 18', 'step4': 'Divide both sides by a-constant to simplify the equation.\nDivide both sides of 3 x = 18 by 3:\n(3 x)/-3 = 18/3', 'step5': 'Any nonzero number divided by itself is one.\n3/3 = 1:\nx-= 18/3', 'step6': 'Reduce 18/3 to lowest terms. Start by finding the greatest-common divisor of 18 and 3.\nThe greatest common divisor of 18 and 3 is 3, so-factor out 3 from both the numerator and denominator: 18/3 = (3x6)/(3x1) = 3/3-x 6 = 6\nAnswer: | \n | x = 6'}}+{'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/+MSP366132eb05g1g302ac200006af0d8f282hd4a5h?MSPStoreType=image/gif&s=1'},+{'title': 'Periodic table location', 'description': None, 'image_url':+'https://www6b3.wolframalpha.com/Calculate/MSP/+MSP367132eb05g1g302ac2000023743068d984gci9?MSPStoreType=image/gif&s=1'},+{'title': 'Images', 'description': None, 'image_url': 'https://www6b3.+wolframalpha.com/Calculate/MSP/MSP368132eb05g1g302ac200004eada51igi7h1bbd?+MSPStoreType=image/gif&s=1'}, {'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 | ...==============================================================================='''-res_llm = WolframAlphaToolkit().query_wolfram_llm(query="solve 3x-7=11")+res_llm = WolframAlphaToolkit().query_wolfram_llm(+ query="10 densest elemental metals"+)print(res_llm)--'''-===============================================================================-'Query:\n"solve 3x-7=11"\n\nInput interpretation:\nsolve 3 x - 7 = 11\n\nResult-:\nx = 6\n\nPlot:\nimage: https://www6b3.wolframalpha.com/Calculate/MSP/MSP6802-0g1bg1ih5hce47h000016g8h3d8220352g2?MSPStoreType=image/png&s=2\nWolfram-Language code: Plot[{-7 + 3 x, 11}, {x, -9., 9.}]\n\nNumber line:\nimage:-https://www6b3.wolframalpha.com/Calculate/MSP/MSP68120g1bg1ih5hce47h000047d112-d53f34d535?MSPStoreType=image/png&s=2\nWolfram Language code: NumberLinePlot[x-== 6, x]\n\nWolfram|Alpha website result for "solve 3x-7=11":\nhttps://www6b3-.wolframalpha.com/input?i=solve+3x-7%3D11'-===============================================================================-'''