diff --git a/README.md b/README.md index f6b85deff..f17bdba2e 100644 --- a/README.md +++ b/README.md @@ -57,18 +57,36 @@ AgentOps helps developers build, evaluate, and monitor AI agents. From prototype ## Key Integrations ๐ +### Agent Frameworks
+ +### LLM Providers + @@ -79,31 +97,39 @@ 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, AG2 (AutoGen), Camel AI, & LangChain | +| ๐ค **Framework Integrations** | Native Integrations with OpenAI Agents, CrewAI, AG2, LangChain, Google ADK, Smolagents & more | ## Quick Start โจ๏ธ +### Installation +First, install the AgentOps SDK. We recommend including `python-dotenv` for easy API key management. + ```bash -pip install agentops +pip install agentops python-dotenv ``` +### Initial Setup (2 Lines of Code) -#### Session replays in 2 lines of code - -Initialize the AgentOps client and automatically get analytics on all your LLM calls. +At its simplest, AgentOps can start monitoring your supported LLM and agent framework calls with just two lines of Python code. [Get an API key](https://app.agentops.ai/settings/projects) ```python import agentops +import os +from dotenv import load_dotenv -# Beginning of your program (i.e. main.py, __init__.py) -agentops.init( < INSERT YOUR API KEY HERE >) +# Load environment variables (recommended for API keys) +load_dotenv() -... +# Initialize AgentOps +# The API key can be passed directly or set as an environment variable AGENTOPS_API_KEY +AGENTOPS_API_KEY = os.getenv("AGENTOPS_API_KEY") +agentops.init(AGENTOPS_API_KEY) -# End of program -agentops.end_session('Success') +# That's it for basic auto-instrumentation! +# If you're using a supported library (like OpenAI, LangChain, CrewAI, etc.), +# AgentOps will now automatically track LLM calls and agent actions. ``` All your sessions can be viewed on the [AgentOps dashboard](https://app.agentops.ai?ref=gh) @@ -146,66 +172,52 @@ Add powerful observability to your agents, tools, and functions with as little c Refer to our [documentation](http://docs.agentops.ai) ```python -# Create a session span (root for all other spans) -from agentops.sdk.decorators import session +# Track custom operations with @operation +from agentops.sdk.decorators import operation -@session -def my_workflow(): - # Your session code here - return result +@operation +def process_data(data): + # Your function logic here + processed_result = data.upper() + return processed_result ``` ```python -# Create an agent span for tracking agent operations -from agentops.sdk.decorators import agent +# Track agent logic with @agent +from agentops.sdk.decorators import agent, operation -@agent +@agent(name="MyCustomAgent") class MyAgent: - def __init__(self, name): - self.name = name + def __init__(self, agent_id): + self.agent_id = agent_id - # Agent methods here -``` - -```python -# Create operation/task spans for tracking specific operations -from agentops.sdk.decorators import operation, task - -@operation # or @task -def process_data(data): - # Process the data - return result + @operation + def perform_task(self, task_description): + # Agent task logic here + return f"Agent {self.agent_id} completed: {task_description}" ``` ```python -# Create workflow spans for tracking multi-operation workflows -from agentops.sdk.decorators import workflow +# Track tools with @tool +from agentops.sdk.decorators import tool -@workflow -def my_workflow(data): - # Workflow implementation - return result +@tool(name="WebSearchTool", cost=0.05) +def web_search(query: str) -> str: + # Tool logic here + return f"Search results for: {query}" ``` ```python -# Nest decorators for proper span hierarchy -from agentops.sdk.decorators import session, agent, operation - -@agent -class MyAgent: - @operation - def nested_operation(self, message): - return f"Processed: {message}" - - @operation - def main_operation(self): - result = self.nested_operation("test message") - return result +# Group operations with @trace +from agentops.sdk.decorators import trace -@session -def my_session(): - agent = MyAgent() - return agent.main_operation() +@trace(name="MyMainWorkflow", tags=["main-flow"]) +def my_workflow(task_to_perform): + # Your workflow code here + main_agent = MyAgent(agent_id="workflow-agent") + result = main_agent.perform_task(task_to_perform) + tool_result = web_search(f"details for {task_to_perform}") + return result, tool_result ``` All decorators support: @@ -214,6 +226,7 @@ All decorators support: - Async/await functions - Generator functions - Custom attributes and names +- Hierarchical span nesting ## Integrations ๐ฆพ @@ -247,12 +260,17 @@ Build Crew agents with observability in just 2 lines of code. Simply set an `AGE pip install 'crewai[agentops]' ``` -- [AgentOps integration example](https://docs.agentops.ai/v1/integrations/crewai) +- [AgentOps integration example](https://docs.agentops.ai/v2/integrations/crewai) - [Official CrewAI documentation](https://docs.crewai.com/how-to/AgentOps-Observability) ### AG2 ๐ค With only two lines of code, add full observability and monitoring to AG2 (formerly AutoGen) agents. Set an `AGENTOPS_API_KEY` in your environment and call `agentops.init()` +```bash +pip install agentops pyautogen +``` + +- [AG2 Integration Guide](https://docs.agentops.ai/v2/integrations/ag2) - [AG2 Observability Example](https://docs.ag2.ai/notebooks/agentchat_agentops) - [AG2 - AgentOps Documentation](https://docs.ag2.ai/docs/ecosystem/agentops) @@ -357,7 +375,7 @@ Check out the [Langchain Examples Notebook](./examples/langchain/langchain_examp First class support for Cohere(>=5.4.0). This is a living integration, should you need any added functionality please message us on Discord! -- [AgentOps integration example](https://docs.agentops.ai/v1/integrations/cohere) +- [AgentOps integration example](https://docs.agentops.ai/v2/integrations/cohere) - [Official Cohere documentation](https://docs.cohere.com/reference/about)