文章目录
- 一、关于 AgentOps
- 二、关键集成 🔌
- 三、快速开始 ⌨️
- 2行代码中的Session replays
- 首类开发者体验
- 四、集成 🦾
- OpenAI Agents SDK 🖇️
- CrewAI 🛶
- AG2 🤖
- Camel AI 🐪
- Langchain 🦜🔗
- Cohere ⌨️
- Anthropic ﹨
- Mistral 〽️
- CamelAI ﹨
- LiteLLM 🚅
- LlamaIndex 🦙
- Llama Stack 🦙🥞
- SwarmZero AI 🐝
- 五、时间旅行调试 🔮
- 六、Agent Arena 🥊
- 七、评估路线图 🧭
- 八、调试路线图 🧭
- 为什么选择 AgentOps? 🤔
- 九、使用 AgentOps 的热门项目
一、关于 AgentOps
AgentOps 帮助开发者构建、评估和监控 AI 代理。从原型到生产。
- github : https://github.com/AgentOps-AI/agentops
- 官方文档:https://docs.agentops.ai/introduction
- 文档对话:https://www.entelligence.ai/AgentOps-AI&agentops
- Dashboard : https://app.agentops.ai/?ref=gh
- Twitter | Discord
视频示例: agentops_demo.mp4
二、关键集成 🔌
- https://docs.agentops.ai/v1/integrations/openai-agents
- https://docs.agentops.ai/v1/integrations/crewai
- https://docs.ag2.ai/docs/ecosystem/agentops
- https://docs.agentops.ai/v1/integrations/microsoft
- https://docs.agentops.ai/v1/integrations/langchain
- https://docs.agentops.ai/v1/integrations/camel
- https://docs.llamaindex.ai/en/stable/module_guides/observability/?h=agentops#agentops
- https://docs.agentops.ai/v1/integrations/cohere
📊 重放分析和调试 | 步骤式代理执行图 |
💸 LLM 成本管理 | 跟踪 LLM 基础模型提供商的花费 |
🧪 代理基准测试 | 将您的代理与 1,000+ 评估进行测试 |
🔐 合规性和安全性 | 检测常见的提示注入和数据泄露攻击 |
🤝 框架集成 | 与 CrewAI、AG2 (AutoGen)、Camel AI 和 LangChain 的原生集成 |
三、快速开始 ⌨️
pip install agentops
2行代码中的Session replays
初始化 AgentOps 客户端并自动获取所有 LLM 调用的分析。
获取API密钥:https://app.agentops.ai/settings/projects
import agentops
# Beginning of your program (i.e. main.py, __init__.py)
agentops.init( < INSERT YOUR API KEY HERE >)
...
# End of program
agentops.end_session('Success')
所有您的会话都可以在AgentOps仪表板上查看
Agent Debugging
Session Replays
Summary Analytics
首类开发者体验
使用尽可能少的代码为您的代理、工具和函数添加强大的可观察性:一次一行。
参考文档: http://docs.agentops.ai
# Create a session span (root for all other spans)
from agentops.sdk.decorators import session
@session
def my_workflow():
# Your session code here
return result
# Create an agent span for tracking agent operations
from agentops.sdk.decorators import agent
@agent
class MyAgent:
def __init__(self, name):
self.name = name
# Agent methods here
# 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
# Create workflow spans for tracking multi-operation workflows
from agentops.sdk.decorators import workflow
@workflow
def my_workflow(data):
# Workflow implementation
return result
# 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
@session
def my_session():
agent = MyAgent()
return agent.main_operation()
所有装饰器支持:
- 输入/输出记录
- 异常处理
- 异步/等待函数
- 发电机功能
- 自定义属性和名称
四、集成 🦾
OpenAI Agents SDK 🖇️
构建多智能体系统,使用工具、交接和防护措施。AgentOps 提供与 OpenAI Agents 的一级集成。
pip install agents-sdk
- AgentOps集成示例
- 官方CrewAI文档
CrewAI 🛶
只需两行代码即可构建具有可观察性的Build Crew代理。只需在您的环境中设置AGENTOPS_API_KEY
,您的队伍将在AgentOps仪表板上获得自动监控。
pip install 'crewai[agentops]'
- AgentOps 集成示例
- 官方 CrewAI 文档
AG2 🤖
只需两行代码,即可为AG2(前身为AutoGen)代理添加完整的可观察性和监控。在你的环境中设置一个AGENTOPS_API_KEY
并调用agentops.init()
- AG2 可观测性示例
- AG2 - 代理操作文档
Camel AI 🐪
跟踪和分析具有完全可观测性的CAMEL代理。在您的环境中设置AGENTOPS_API_KEY
并初始化AgentOps以开始使用。
- Camel AI - 高级代理通信框架
- AgentOps 集成示例
- 官方 Camel AI 文档
安装
pip install "camel-ai[all]==0.2.11"
pip install agentops
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")
查看我们的Camel集成指南以获取更多示例,包括多代理场景。
Langchain 🦜🔗
AgentOps可以无缝地与使用Langchain构建的应用程序协同工作。要使用此处理程序,将Langchain作为可选依赖项安装:
安装
pip install agentops[langchain]
要使用处理器,导入并设置
import os
from langchain.chat_models import ChatOpenAI
from langchain.agents import initialize_agent, AgentType
from agentops.partners.langchain_callback_handler import LangchainCallbackHandler
AGENTOPS_API_KEY = os.environ['AGENTOPS_API_KEY']
handler = LangchainCallbackHandler(api_key=AGENTOPS_API_KEY, tags=['Langchain Example'])
llm = ChatOpenAI(openai_api_key=OPENAI_API_KEY,
callbacks=[handler],
model='gpt-3.5-turbo')
agent = initialize_agent(tools,
llm,
agent=AgentType.CHAT_ZERO_SHOT_REACT_DESCRIPTION,
verbose=True,
callbacks=[handler], # You must pass in a callback handler to record your agent
handle_parsing_errors=True)
查看Langchain 示例笔记本以获取更多详细信息,包括异步处理程序。
Cohere ⌨️
首先类支持 Cohere(>=5.4.0)。这是一个持续集成的项目,如果您需要任何额外的功能,请通过 Discord 联系我们!
- AgentOps集成示例
- 官方Cohere文档
安装
pip install cohere
import cohere
import agentops
# Beginning of program's code (i.e. main.py, __init__.py)
agentops.init(<INSERT YOUR API KEY HERE>)
co = cohere.Client()
chat = co.chat(
message="Is it pronounced ceaux-hear or co-hehray?"
)
print(chat)
agentops.end_session('Success')
import cohere
import agentops
# Beginning of program's code (i.e. main.py, __init__.py)
agentops.init(<INSERT YOUR API KEY HERE>)
co = cohere.Client()
stream = co.chat_stream(
message="Write me a haiku about the synergies between Cohere and AgentOps"
)
for event in stream:
if event.event_type == "text-generation":
print(event.text, end='')
agentops.end_session('Success')
Anthropic ﹨
跟踪代理使用Anthropic Python SDK(>=0.32.0)构建。
- AgentOps 集成指南
- 官方Anthropic文档
安装
pip install anthropic
import anthropic
import agentops
# Beginning of program's code (i.e. main.py, __init__.py)
agentops.init(<INSERT YOUR API KEY HERE>)
client = anthropic.Anthropic(
# This is the default and can be omitted
api_key=os.environ.get("ANTHROPIC_API_KEY"),
)
message = client.messages.create(
max_tokens=1024,
messages=[
{
"role": "user",
"content": "Tell me a cool fact about AgentOps",
}
],
model="claude-3-opus-20240229",
)
print(message.content)
agentops.end_session('Success')
流式传输
import anthropic
import agentops
# Beginning of program's code (i.e. main.py, __init__.py)
agentops.init(<INSERT YOUR API KEY HERE>)
client = anthropic.Anthropic(
# This is the default and can be omitted
api_key=os.environ.get("ANTHROPIC_API_KEY"),
)
stream = client.messages.create(
max_tokens=1024,
model="claude-3-opus-20240229",
messages=[
{
"role": "user",
"content": "Tell me something cool about streaming agents",
}
],
stream=True,
)
response = ""
for event in stream:
if event.type == "content_block_delta":
response += event.delta.text
elif event.type == "message_stop":
print("\n")
print(response)
print("\n")
异步
import asyncio
from anthropic import AsyncAnthropic
client = AsyncAnthropic(
# This is the default and can be omitted
api_key=os.environ.get("ANTHROPIC_API_KEY"),
)
async def main() -> None:
message = await client.messages.create(
max_tokens=1024,
messages=[
{
"role": "user",
"content": "Tell me something interesting about async agents",
}
],
model="claude-3-opus-20240229",
)
print(message.content)
await main()
Mistral 〽️
使用 Mistral Python SDK (>=0.32.0) 构建的跟踪代理。
- AgentOps集成示例
- Mistral官方文档
pip install mistralai
Sync
from mistralai import Mistral
import agentops
# Beginning of program's code (i.e. main.py, __init__.py)
agentops.init(<INSERT YOUR API KEY HERE>)
client = Mistral(
# This is the default and can be omitted
api_key=os.environ.get("MISTRAL_API_KEY"),
)
message = client.chat.complete(
messages=[
{
"role": "user",
"content": "Tell me a cool fact about AgentOps",
}
],
model="open-mistral-nemo",
)
print(message.choices[0].message.content)
agentops.end_session('Success')
流
from mistralai import Mistral
import agentops
# Beginning of program's code (i.e. main.py, __init__.py)
agentops.init(<INSERT YOUR API KEY HERE>)
client = Mistral(
# This is the default and can be omitted
api_key=os.environ.get("MISTRAL_API_KEY"),
)
message = client.chat.stream(
messages=[
{
"role": "user",
"content": "Tell me something cool about streaming agents",
}
],
model="open-mistral-nemo",
)
response = ""
for event in message:
if event.data.choices[0].finish_reason == "stop":
print("\n")
print(response)
print("\n")
else:
response += event.text
agentops.end_session('Success')
异步
import asyncio
from mistralai import Mistral
client = Mistral(
# This is the default and can be omitted
api_key=os.environ.get("MISTRAL_API_KEY"),
)
async def main() -> None:
message = await client.chat.complete_async(
messages=[
{
"role": "user",
"content": "Tell me something interesting about async agents",
}
],
model="open-mistral-nemo",
)
print(message.choices[0].message.content)
await main()
异步流
import asyncio
from mistralai import Mistral
client = Mistral(
# This is the default and can be omitted
api_key=os.environ.get("MISTRAL_API_KEY"),
)
async def main() -> None:
message = await client.chat.stream_async(
messages=[
{
"role": "user",
"content": "Tell me something interesting about async streaming agents",
}
],
model="open-mistral-nemo",
)
response = ""
async for event in message:
if event.data.choices[0].finish_reason == "stop":
print("\n")
print(response)
print("\n")
else:
response += event.text
await main()
CamelAI ﹨
使用 CamelAI Python SDK (>=0.32.0) 构建的 Track agents。
- CamelAI集成指南
- CamelAI官方文档
安装
pip install camel-ai[all]
pip install agentops
#Import Dependencies
import agentops
import os
from getpass import getpass
from dotenv import load_dotenv
#Set Keys
load_dotenv()
openai_api_key = os.getenv("OPENAI_API_KEY") or "<your openai key here>"
agentops_api_key = os.getenv("AGENTOPS_API_KEY") or "<your agentops key here>"
您可以在这里找到使用示例!:
https://github.com/AgentOps-AI/agentops/blob/main/examples/camelai_examples/README.md
LiteLLM 🚅
AgentOps 提供了对 LiteLLM(>=1.3.1) 的支持,允许您使用相同的输入/输出格式调用 100+ 个 LLM。
- AgentOps 集成示例
- 官方 LiteLLM 文档
安装
pip install litellm
# Do not use LiteLLM like this
# from litellm import completion
# ...
# response = completion(model="claude-3", messages=messages)
# Use LiteLLM like this
import litellm
...
response = litellm.completion(model="claude-3", messages=messages)
# or
response = await litellm.acompletion(model="claude-3", messages=messages)
LlamaIndex 🦙
AgentOps 与使用 LlamaIndex 构建的应用无缝协作,LlamaIndex 是一个用于构建具有 LLM 的上下文增强生成式 AI 应用程序的框架。
安装
pip install llama-index-instrumentation-agentops
为了使用该处理器,导入并设置
from llama_index.core import set_global_handler
# NOTE: Feel free to set your AgentOps environment variables (e.g., 'AGENTOPS_API_KEY')
# as outlined in the AgentOps documentation, or pass the equivalent keyword arguments
# anticipated by AgentOps' AOClient as **eval_params in set_global_handler.
set_global_handler("agentops")
查看LlamaIndex 文档 以获取更多详情。
Llama Stack 🦙🥞
AgentOps 提供了对 Llama Stack Python 客户端(>=0.0.53)的支持,允许您监控您的 Agentic 应用程序。
- AgentOps集成示例1
- AgentOps集成示例2
- 官方 Llama Stack Python 客户端
SwarmZero AI 🐝
跟踪和分析 SwarmZero 代理,具有全面的可观察性。在你的环境中设置一个 AGENTOPS_API_KEY
,然后初始化 AgentOps 以开始使用。
- SwarmZero - 高级多智能体框架
- AgentOps集成示例
- SwarmZero AI 集成示例
- SwarmZero AI - 代理操作文档
- SwarmZero 官方 Python SDK
安装
pip install swarmzero
pip install agentops
from dotenv import load_dotenv
load_dotenv()
import agentops
agentops.init(<INSERT YOUR API KEY HERE>)
from swarmzero import Agent, Swarm
# ...
五、时间旅行调试 🔮
试试 : https://app.agentops.ai/timetravel
六、Agent Arena 🥊
(即将推出!)
七、评估路线图 🧭
平台 | 仪表板 | 评估 |
---|---|---|
✅ Python SDK | ✅ 多会话和跨会话指标 | ✅ 自定义评估指标 |
🚧 评估构建器 API | ✅ 自定义事件标签跟踪 | 🔜 代理分数卡 |
✅ Javascript/Typescript SDK | ✅ 会话重放 | 🔜 评估游乐场 + 排行榜 |
八、调试路线图 🧭
性能测试 | 环境 | LLM 测试 | 推理和执行测试 |
---|---|---|---|
✅ 事件延迟分析 | 🔜 非平稳环境测试 | 🔜 LLM 非确定性函数检测 | 🚧 无限循环和递归思维检测 |
✅ 代理工作流程执行定价 | 🔜 多模态环境 | 🚧 令牌限制溢出标志 | 🔜 故障推理检测 |
🚧 成功验证器(外部) | 🔜 执行容器 | 🔜 上下文限制溢出标志 | 🔜 生成代码验证器 |
🔜 代理控制器/技能测试 | ✅ 蜜罐和提示注入检测 (PromptArmor) | 🔜 API 账单跟踪 | 🔜 错误断点分析 |
🔜 信息上下文约束测试 | 🔜 反代理障碍(例如,验证码) | 🔜 CI/CD 集成检查 | |
🔜 回归测试 | 🔜 多代理框架可视化 |
为什么选择 AgentOps? 🤔
没有合适的工具,AI代理将变得缓慢、昂贵且不可靠。我们的使命是将您的代理从原型过渡到生产。以下是AgentOps脱颖而出的原因:
- 全面可观察性: 跟踪您的AI代理的性能、用户交互和API使用情况。
- 实时监控:通过会话回放、指标和实时监控工具立即获得洞察。
- 成本控制:监控和管理你在LLM和API调用上的支出。
- 故障检测:快速识别并响应代理故障和多代理交互问题。
- 工具使用统计: 了解您的代理如何使用外部工具,并通过详细的分析来理解。
- 会话级指标:通过全面的统计数据获得您代理人的会话的整体视图。
AgentOps 是设计用来让代理的可观察性、测试和监控变得简单。
九、使用 AgentOps 的热门项目
Repository | Stars |
---|---|
geekan / MetaGPT | 42787 |
run-llama / llama_index | 34446 |
crewAIInc / crewAI | 18287 |
camel-ai / camel | 5166 |
superagent-ai / superagent | 5050 |
iyaja / llama-fs | 4713 |
BasedHardware / Omi | 2723 |
MervinPraison / PraisonAI | 2007 |
AgentOps-AI / Jaiqu | 272 |
swarmzero / swarmzero | 195 |
strnad / CrewAI-Studio | 134 |
alejandro-ao / exa-crewai | 55 |
tonykipkemboi / youtube_yapper_trapper | 47 |
sethcoast / cover-letter-builder | 27 |
bhancockio / chatgpt4o-analysis | 19 |
breakstring / Agentic_Story_Book_Workflow | 14 |
MULTI-ON / multion-python | 13 |
Generated using github-dependents-info, by Nicolas Vuillamy
2025-04-16(三)