文档索引
获取完整文档索引: https://docs.crewai.com.cn/llms.txt
在深入了解之前,请使用此文件来浏览所有可用页面。
OpenLIT 概览
OpenLIT 是一个开源工具,只需 一行 代码即可轻松监控 AI 智能体、大语言模型 (LLM)、向量数据库和 GPU 的性能。 它提供原生 OpenTelemetry 追踪和指标,用于跟踪成本、延迟、交互和任务序列等重要参数。此设置使您能够追踪超参数并监控性能问题,从而帮助您寻找随时间推移来增强和微调智能体的方法。
- 分析仪表板:通过跟踪指标、成本和用户交互的详细仪表板,监控智能体的健康状况和性能。
- 原生 OpenTelemetry 可观测性 SDK:厂商中立的 SDK,可将追踪和指标发送到您现有的可观测性工具(如 Grafana、DataDog 等)。
- 自定义和微调模型的成本追踪:使用自定义定价文件为特定模型定制成本估算,以实现精确的预算管理。
- 异常监控仪表板:通过监控仪表板跟踪常见异常和错误,快速发现并解决问题。
- 合规与安全:检测潜在威胁,例如亵渎内容和个人身份信息 (PII) 泄露。
- 提示词注入检测:识别潜在的代码注入和密钥泄露。
- API 密钥与密钥管理:集中式安全管理您的 LLM API 密钥和敏感信息,避免不安全的做法。
- 提示词管理:使用 PromptHub 管理和版本控制智能体提示词,确保在不同智能体间的一致性和易用性。
- 模型操场:在部署前测试并比较用于 CrewAI 智能体的不同模型。
设置说明
部署 OpenLIT
克隆 OpenLIT 仓库
git clone git@github.com:openlit/openlit.git
在您的应用中初始化 OpenLIT
在您的应用程序代码中添加以下两行import openlit
openlit.init(otlp_endpoint="http://127.0.0.1:4318")
监控 CrewAI 智能体的使用示例from crewai import Agent, Task, Crew, Process
import openlit
openlit.init(disable_metrics=True)
# Define your agents
researcher = Agent(
role="Researcher",
goal="Conduct thorough research and analysis on AI and AI agents",
backstory="You're an expert researcher, specialized in technology, software engineering, AI, and startups. You work as a freelancer and are currently researching for a new client.",
allow_delegation=False,
llm='command-r'
)
# Define your task
task = Task(
description="Generate a list of 5 interesting ideas for an article, then write one captivating paragraph for each idea that showcases the potential of a full article on this topic. Return the list of ideas with their paragraphs and your notes.",
expected_output="5 bullet points, each with a paragraph and accompanying notes.",
)
# Define the manager agent
manager = Agent(
role="Project Manager",
goal="Efficiently manage the crew and ensure high-quality task completion",
backstory="You're an experienced project manager, skilled in overseeing complex projects and guiding teams to success. Your role is to coordinate the efforts of the crew members, ensuring that each task is completed on time and to the highest standard.",
allow_delegation=True,
llm='command-r'
)
# Instantiate your crew with a custom manager
crew = Crew(
agents=[researcher],
tasks=[task],
manager_agent=manager,
process=Process.hierarchical,
)
# Start the crew's work
result = crew.kickoff()
print(result)
在您的应用程序代码中添加以下两行import openlit
openlit.init()
运行以下命令来配置 OTEL 导出端点export OTEL_EXPORTER_OTLP_ENDPOINT = "http://127.0.0.1:4318"
监控 CrewAI 异步智能体的使用示例import asyncio
from crewai import Crew, Agent, Task
import openlit
openlit.init(otlp_endpoint="http://127.0.0.1:4318")
# Create an agent with code execution enabled
coding_agent = Agent(
role="Python Data Analyst",
goal="Analyze data and provide insights using Python",
backstory="You are an experienced data analyst with strong Python skills.",
allow_code_execution=True,
llm="command-r"
)
# Create a task that requires code execution
data_analysis_task = Task(
description="Analyze the given dataset and calculate the average age of participants. Ages: {ages}",
agent=coding_agent,
expected_output="5 bullet points, each with a paragraph and accompanying notes.",
)
# Create a crew and add the task
analysis_crew = Crew(
agents=[coding_agent],
tasks=[data_analysis_task]
)
# Async function to kickoff the crew asynchronously
async def async_crew_execution():
result = await analysis_crew.kickoff_async(inputs={"ages": [25, 30, 35, 40, 45]})
print("Crew Result:", result)
# Run the async function
asyncio.run(async_crew_execution())
有关更多高级配置和用例,请参阅 OpenLIT Python SDK 仓库。 可视化与分析
随着智能体可观测性数据被收集并发送到 OpenLIT,下一步就是可视化和分析这些数据,以获取有关智能体性能、行为的见解,并确定需要改进的领域。只需在浏览器中访问 127.0.0.1:3000 即可开始探索 OpenLIT。您可以使用默认凭据登录
- 电子邮件:
user@openlit.io
- 密码:
openlituser