Python SDK for AI agent monitoring, LLM cost tracking, benchmarking, and more. Integrates with most LLMs and agent frameworks including CrewAI, Agno, OpenAI Agents SDK, Langchain, Autogen, AG2, and CamelAI
Python agentagentopsagents-sdkaianthropicautogencost-estimationcrewaievalsevaluation-metricsgroqlangchainllmmistralollamaopenaiopenai-agents
docs: add Camel AI integration documentation (#573)
devin-ai-integration[bot]a03e45a01e05
diff --git a/README.md b/README.mdindex e87981df..98fdbd86 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)++<details>+ <summary>Installation</summary>++```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.+</details>+### 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.jsonindex 55c7246e..6751cf79 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.mdxnew file mode 100644index 00000000..9f94c8b9--- /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++<Steps>+ <Step title="Install the AgentOps SDK">+ <CodeGroup>+ ```bash pip+ pip install agentops+ ```+ ```bash poetry+ poetry add agentops+ ```+ </CodeGroup>+ </Step>+ <Step title="Install CAMEL">+ <CodeGroup>+ ```bash pip+ pip install "camel-ai[all]==0.2.11"+ ```+ ```bash poetry+ poetry add "camel-ai[all]==0.2.11"+ ```+ </CodeGroup>+ </Step>+ <Step title="Add 3 lines of code">+ <CodeTooltip/>+ <CodeGroup>+ ```python python+ import agentops+ agentops.init(<INSERT YOUR API KEY HERE>)+ ...+ # MUST END SESSION at end of program+ agentops.end_session("Success") # Success|Fail|Indeterminate+ ```+ </CodeGroup>+ <EnvTooltip />+ <CodeGroup>+ ```python .env+ AGENTOPS_API_KEY=<YOUR API KEY>+ ```+ </CodeGroup>+ Read more about environment variables in [Advanced Configuration](/v1/usage/advanced-configuration)+ </Step>+ <Step title="Run your agent">+ Execute your program and visit [app.agentops.ai/drilldown](https://app.agentops.ai/drilldown) to observe your CAMEL Agent! 🕵️+ <Tip>+ After your run, AgentOps prints a clickable url to console linking directly to your session in the Dashboard+ </Tip>+ <div/>{/* Intentionally blank div for newline */}+ <Frame type="glass" caption="Clickable link to session">+ <img height="200" src="https://github.com/AgentOps-AI/agentops/blob/main/docs/images/link-to-session.gif?raw=true" />+ </Frame>+ </Step>+</Steps>++## 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).++<script type="module" src="/scripts/github_stars.js"></script>+<script type="module" src="/scripts/scroll-img-fadein-animation.js"></script>+<script type="module" src="/scripts/button_heartbeat_animation.js"></script>+<script type="css" src="/styles/styles.css"></script>+<script type="module" src="/scripts/adjust_api_dynamically.js"></script>diff --git a/examples/camel_examples/camel_example.ipynb b/examples/camel_examples/camel_example.ipynbnew file mode 100644index 00000000..90fb949c--- /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+}