From a03e45a01e05bfd809d34843c834fffc742d22f1 Mon Sep 17 00:00:00 2001 From: "devin-ai-integration[bot]" <158243242+devin-ai-integration[bot]@users.noreply.github.com> Date: Fri, 13 Dec 2024 09:26:18 -0800 Subject: [PATCH] docs: add Camel AI integration documentation (#573) * docs: add Camel AI integration documentation Add comprehensive Camel AI integration support: - Add integration page in docs - Update README with Camel AI framework - Add example notebook and verification script - Update mint.json navigation Note: Documentation and examples have been verified for: - Package installation - Import compatibility - Code syntax and structure Testing limitations: - Full execution testing requires API keys - Example notebook execution pending API access Closes #521 Co-Authored-By: Alex Reibman * style: fix Python formatting in Camel example files Co-Authored-By: Alex Reibman * style: fix Python formatting in Camel example files Co-Authored-By: Alex Reibman * style: fix Python formatting in Camel example files Co-Authored-By: Alex Reibman * fix: update Camel AI integration with working analytics and examples Co-Authored-By: Alex Reibman * style: fix Python formatting in Camel example files Co-Authored-By: Alex Reibman * fix: address PR comments for Camel AI integration Co-Authored-By: Alex Reibman * docs: update CAMEL example with multi-agent interaction Co-Authored-By: Alex Reibman --------- Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> Co-authored-by: Alex Reibman --- README.md | 61 ++++++- docs/mint.json | 3 +- docs/v1/integrations/camel.mdx | 148 +++++++++++++++++ examples/camel_examples/camel_example.ipynb | 172 ++++++++++++++++++++ 4 files changed, 382 insertions(+), 2 deletions(-) create mode 100644 docs/v1/integrations/camel.mdx create mode 100644 examples/camel_examples/camel_example.ipynb diff --git a/README.md b/README.md index e87981dfa..98fdbd861 100644 --- a/README.md +++ b/README.md @@ -58,7 +58,7 @@ AgentOps helps developers build, evaluate, and monitor AI agents. From prototype | ๐Ÿ’ธ **LLM Cost Management** | Track spend with LLM foundation model providers | | ๐Ÿงช **Agent Benchmarking** | Test your agents against 1,000+ evals | | ๐Ÿ” **Compliance and Security** | Detect common prompt injection and data exfiltration exploits | -| ๐Ÿค **Framework Integrations** | Native Integrations with CrewAI, AutoGen, & LangChain | +| ๐Ÿค **Framework Integrations** | Native Integrations with CrewAI, AutoGen, Camel AI, & LangChain | ## Quick Start โŒจ๏ธ @@ -177,6 +177,65 @@ With only two lines of code, add full observability and monitoring to Autogen ag - [Autogen Observability Example](https://microsoft.github.io/autogen/docs/notebooks/agentchat_agentops) - [Autogen - AgentOps Documentation](https://microsoft.github.io/autogen/docs/ecosystem/agentops) +### Camel AI ๐Ÿช + +Track and analyze CAMEL agents with full observability. Set an `AGENTOPS_API_KEY` in your environment and initialize AgentOps to get started. + +- [Camel AI](https://www.camel-ai.org/) - Advanced agent communication framework +- [AgentOps integration example](https://docs.agentops.ai/v1/integrations/camel) +- [Official Camel AI documentation](https://docs.camel-ai.org/cookbooks/agents_tracking.html) + +
+ Installation + +```bash +pip install "camel-ai[all]==0.2.11" +pip install agentops +``` + +```python +import os +import agentops +from camel.agents import ChatAgent +from camel.messages import BaseMessage +from camel.models import ModelFactory +from camel.types import ModelPlatformType, ModelType + +# Initialize AgentOps +agentops.init(os.getenv("AGENTOPS_API_KEY"), default_tags=["CAMEL Example"]) + +# Import toolkits after AgentOps init for tracking +from camel.toolkits import SearchToolkit + +# Set up the agent with search tools +sys_msg = BaseMessage.make_assistant_message( + role_name='Tools calling operator', + content='You are a helpful assistant' +) + +# Configure tools and model +tools = [*SearchToolkit().get_tools()] +model = ModelFactory.create( + model_platform=ModelPlatformType.OPENAI, + model_type=ModelType.GPT_4O_MINI, +) + +# Create and run the agent +camel_agent = ChatAgent( + system_message=sys_msg, + model=model, + tools=tools, +) + +response = camel_agent.step("What is AgentOps?") +print(response) + +agentops.end_session("Success") +``` + +Check out our [Camel integration guide](https://docs.agentops.ai/v1/integrations/camel) for more examples including multi-agent scenarios. +
+ ### Langchain ๐Ÿฆœ๐Ÿ”— AgentOps works seamlessly with applications built using Langchain. To use the handler, install Langchain as an optional dependency: diff --git a/docs/mint.json b/docs/mint.json index 55c7246e4..6751cf79b 100644 --- a/docs/mint.json +++ b/docs/mint.json @@ -17,7 +17,7 @@ "anchors": { "from": "#D1E5F7", "to": "#a9bed4" - + } }, "topbarCtaButton": { @@ -90,6 +90,7 @@ "v1/integrations/ai21", "v1/integrations/anthropic", "v1/integrations/autogen", + "v1/integrations/camel", "v1/integrations/cohere", "v1/integrations/crewai", "v1/integrations/groq", diff --git a/docs/v1/integrations/camel.mdx b/docs/v1/integrations/camel.mdx new file mode 100644 index 000000000..9f94c8b9e --- /dev/null +++ b/docs/v1/integrations/camel.mdx @@ -0,0 +1,148 @@ +--- +title: 'Camel AI' +description: 'Track and analyze CAMEL agents including LLMs and Tools usage with AgentOps' +--- + +import CodeTooltip from '/snippets/add-code-tooltip.mdx' +import EnvTooltip from '/snippets/add-env-tooltip.mdx' + +[CAMEL](https://www.camel-ai.org/) is the first large language model (LLM) multi-agent framework and an open-source community dedicated to finding the scaling law of agents. CAMEL has comprehensive [documentation](https://docs.camel-ai.org/) available as well as a great [quickstart](https://docs.camel-ai.org/getting_started/installation.html) guide. + +## Adding AgentOps to CAMEL agents + + + + + ```bash pip + pip install agentops + ``` + ```bash poetry + poetry add agentops + ``` + + + + + ```bash pip + pip install "camel-ai[all]==0.2.11" + ``` + ```bash poetry + poetry add "camel-ai[all]==0.2.11" + ``` + + + + + + ```python python + import agentops + agentops.init() + ... + # MUST END SESSION at end of program + agentops.end_session("Success") # Success|Fail|Indeterminate + ``` + + + + ```python .env + AGENTOPS_API_KEY= + ``` + + Read more about environment variables in [Advanced Configuration](/v1/usage/advanced-configuration) + + + Execute your program and visit [app.agentops.ai/drilldown](https://app.agentops.ai/drilldown) to observe your CAMEL Agent! ๐Ÿ•ต๏ธ + + After your run, AgentOps prints a clickable url to console linking directly to your session in the Dashboard + +
{/* Intentionally blank div for newline */} + + + + + + +## Single Agent Example with Tools + +Here's a simple example of tracking a CAMEL single agent with tools using AgentOps: + +```python +import agentops +import os +from camel.agents import ChatAgent +from camel.messages import BaseMessage +from camel.models import ModelFactory +from camel.types import ModelPlatformType, ModelType + +# Initialize AgentOps +agentops.init(os.getenv("AGENTOPS_API_KEY")) + +# Import toolkits after AgentOps init for tracking +from camel.toolkits import SearchToolkit + +# Set up the agent with search tools +sys_msg = BaseMessage.make_assistant_message( + role_name='Tools calling operator', + content='You are a helpful assistant' +) + +# Configure tools and model +tools = [*SearchToolkit().get_tools()] +model = ModelFactory.create( + model_platform=ModelPlatformType.OPENAI, + model_type=ModelType.GPT_4O_MINI, +) + +# Create the agent +camel_agent = ChatAgent( + system_message=sys_msg, + model=model, + tools=tools, +) + +# Run the agent +user_msg = 'What is CAMEL-AI.org?' +response = camel_agent.step(user_msg) +print(response) + +# End the session +agentops.end_session("Success") +``` + +## Multi-Agent Example + +For more complex scenarios, CAMEL supports multi-agent interactions. Here's how to track multiple agents: + +```python +import agentops +from typing import List +from camel.agents.chat_agent import FunctionCallingRecord +from camel.societies import RolePlaying +from camel.types import ModelPlatformType, ModelType + +# Initialize AgentOps with multi-agent tag +agentops.start_session(tags=["CAMEL X AgentOps Multi-agent"]) + +# Import toolkits after AgentOps init +from camel.toolkits import SearchToolkit, MathToolkit + +# Set up your task +task_prompt = ( + "Assume now is 2024 in the Gregorian calendar, " + "estimate the current age of University of Oxford " + "and then add 10 more years to this age, " + "and get the current weather of the city where " + "the University is located." +) + +# The rest of your multi-agent implementation... +# See our example notebook for the complete implementation +``` + +For complete examples including multi-agent setups and advanced configurations, check out our [example notebooks](https://github.com/AgentOps-AI/agentops/tree/main/examples/camel_examples). + + + + + + diff --git a/examples/camel_examples/camel_example.ipynb b/examples/camel_examples/camel_example.ipynb new file mode 100644 index 000000000..90fb949cf --- /dev/null +++ b/examples/camel_examples/camel_example.ipynb @@ -0,0 +1,172 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "id": "4b0cfa79", + "metadata": {}, + "source": [ + "# CAMEL AI Multi-Agent Example\n", + "This notebook demonstrates how to use AgentOps with CAMEL AI for monitoring multi-agent interactions." + ] + }, + { + "cell_type": "markdown", + "id": "13e64774", + "metadata": {}, + "source": [ + "First let's install the required packages" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "5a6e7d82", + "metadata": {}, + "outputs": [], + "source": [ + "!pip install camel-ai[all] agentops" + ] + }, + { + "cell_type": "markdown", + "id": "c5e296fc", + "metadata": {}, + "source": [ + "Then import them" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "1c29fa2b", + "metadata": {}, + "outputs": [], + "source": [ + "import os\n", + "import agentops\n", + "from camel.agents import ChatAgent\n", + "from camel.messages import BaseMessage\n", + "from camel.types import ModelType, ModelPlatformType\n", + "from camel.models import ModelFactory" + ] + }, + { + "cell_type": "markdown", + "id": "059be5df", + "metadata": {}, + "source": [ + "Next, we'll set our API keys" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "f999c353", + "metadata": {}, + "outputs": [], + "source": [ + "# Initialize AgentOps\n", + "agentops.init(os.getenv(\"AGENTOPS_API_KEY\"))" + ] + }, + { + "cell_type": "markdown", + "id": "1ef587c7", + "metadata": {}, + "source": [ + "# Multi-Agent Chat Example\n", + "In this example, we'll create two agents: a Python expert who writes code and a code reviewer who provides feedback." + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "cf5b3882", + "metadata": {}, + "outputs": [], + "source": [ + "# Initialize two CAMEL agents\n", + "assistant = ChatAgent(\n", + " model=ModelFactory.create(\n", + " model_platform=ModelPlatformType.OPENAI,\n", + " model_type=ModelType.GPT_4O_MINI,\n", + " ),\n", + " system_message=\"You are a Python expert who helps write clean, efficient code.\"\n", + ")\n", + "\n", + "reviewer = ChatAgent(\n", + " model=ModelFactory.create(\n", + " model_platform=ModelPlatformType.OPENAI,\n", + " model_type=ModelType.GPT_4O_MINI,\n", + " ),\n", + " system_message=\"You are a code reviewer who focuses on code quality and best practices.\"\n", + ")" + ] + }, + { + "cell_type": "markdown", + "id": "d62c6e1e", + "metadata": {}, + "source": [ + "Now let's start a conversation about optimizing a Python function. The assistant will suggest improvements, and the reviewer will provide feedback." + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "42d9a004", + "metadata": {}, + "outputs": [], + "source": [ + "# Start a conversation about code optimization\n", + "message = BaseMessage(\n", + " role_name=\"Human\",\n", + " role_type=\"human\",\n", + " meta_dict={\"timestamp\": \"2024-01-01T00:00:01\"},\n", + " content=\"I need help optimizing this Python function for calculating prime numbers:\\ndef is_prime(n):\\n for i in range(2, n):\\n if n % i == 0:\\n return False\\n return True\"\n", + ")\n", + "\n", + "# Get assistant's response\n", + "assistant_response = assistant.step(message)\n", + "print(\"Assistant's suggestion:\", assistant_response.msgs[0].content)\n", + "\n", + "# Get reviewer's feedback\n", + "reviewer_message = BaseMessage(\n", + " role_name=\"Human\",\n", + " role_type=\"human\",\n", + " meta_dict={\"timestamp\": \"2024-01-01T00:00:02\"},\n", + " content=f\"Please review this code suggestion:\\n{assistant_response.msgs[0].content}\"\n", + ")\n", + "reviewer_response = reviewer.step(reviewer_message)\n", + "print(\"\\nReviewer's feedback:\", reviewer_response.msgs[0].content)\n", + "\n", + "# Implement reviewer's suggestions\n", + "improvement_message = BaseMessage(\n", + " role_name=\"Human\",\n", + " role_type=\"human\",\n", + " meta_dict={\"timestamp\": \"2024-01-01T00:00:03\"},\n", + " content=f\"Please improve the code based on this feedback:\\n{reviewer_response.msgs[0].content}\"\n", + ")\n", + "final_response = assistant.step(improvement_message)\n", + "print(\"\\nFinal improved code:\", final_response.msgs[0].content)" + ] + }, + { + "cell_type": "markdown", + "id": "11fecd6f", + "metadata": {}, + "source": [ + "You can view the complete interaction and agent performance metrics at [app.agentops.ai](https://app.agentops.ai)\n", + "\n", + "In this example, you'll see:\n", + "- Multiple agent initialization and configuration\n", + "- Inter-agent communication and collaboration\n", + "- Code review and improvement workflow\n", + "- Complete tracking of all agent interactions" + ] + } + ], + "metadata": {}, + "nbformat": 4, + "nbformat_minor": 5 +}