🐫 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
docs: Add ACI usage cookbook (#2420)
YueTwoa6d9ff48d9cb
diff --git a/docs/cookbooks/advanced_features/agents_with_tools_from_ACI.ipynb b/docs/cookbooks/advanced_features/agents_with_tools_from_ACI.ipynbnew file mode 100644index 000000000..e37ce96e6--- /dev/null+++ b/docs/cookbooks/advanced_features/agents_with_tools_from_ACI.ipynb@@ -0,0 +1,194 @@+{+ "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"+ ]+ }+ ],+ "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+}diff --git a/docs/cookbooks/advanced_features/index.rst b/docs/cookbooks/advanced_features/index.rstindex 1d97eb50b..0c5ecefb6 100644--- a/docs/cookbooks/advanced_features/index.rst+++ b/docs/cookbooks/advanced_features/index.rst@@ -12,6 +12,7 @@ Advanced Features:maxdepth: 1agents_with_tools+ agents_with_tools_from_ACIagents_with_tools_from_Composioagents_with_human_in_loop_and_tool_approvalagents_with_memory