diff --git a/docs.json b/docs.json index b3a1a165..11b1c9b0 100644 --- a/docs.json +++ b/docs.json @@ -469,6 +469,7 @@ "observability/langwatch", "observability/langsmith", "observability/langtrace", + "observability/maxim", "observability/weave" ] }, diff --git a/images/maxim.gif b/images/maxim.gif new file mode 100644 index 00000000..10e98138 Binary files /dev/null and b/images/maxim.gif differ diff --git a/observability/maxim.mdx b/observability/maxim.mdx new file mode 100644 index 00000000..b83944e1 --- /dev/null +++ b/observability/maxim.mdx @@ -0,0 +1,162 @@ +--- +title: Maxim +description: Integrate Agno with Maxim to send traces and gain insights into your agent's performance. +--- + +## Integrating Agno with Maxim + +Maxim AI provides comprehensive agent monitoring, evaluation, and observability for your Agno applications. With Maxim's one-line integration, you can easily trace and analyse agent interactions, performance metrics, and more. + +## Prerequisites + +1. **Install Dependencies** + + Ensure you have the necessary packages installed: + + ```bash + pip install agno openai maxim-py + ``` + +2. **Setup Maxim Account** + + - Sign up for an account at [Maxim](https://getmaxim.ai/). + - Generate your API key from the Maxim dashboard. + - Create a repository to store your traces. + +3. **Set Environment Variables** + + Configure your environment with the Maxim API key: + + ```bash + export MAXIM_API_KEY= + export MAXIM_LOG_REPO_ID= + export OPENAI_API_KEY= + ``` + +## Sending Traces to Maxim + +### Example: Basic Maxim Integration + +This example demonstrates how to instrument your Agno agent with Maxim and send traces for monitoring and evaluation. + +```python +import os +from dotenv import load_dotenv +from agno.agent import Agent +from agno.models.openai import OpenAIChat +from agno.tools.yfinance import YFinanceTools +from maxim import Maxim +from maxim.logger.agno import instrument_agno + +# Load environment variables +load_dotenv() + +# Instrument Agno with Maxim +instrument_agno(Maxim().logger()) + +# Create and configure the agent +agent = Agent( + name="Stock Price Agent", + model=OpenAIChat(id="gpt-4o"), + tools=[YFinanceTools()], + instructions="You are a stock price agent. Answer questions in the style of a stock analyst.", + show_tool_calls=True, + markdown=True, +) + +# Use the agent +response = agent.run("What is the current price of Tesla?") +print(response.content) +``` + +### Example: Multi-Agent System with Maxim + +This example demonstrates how to set up a multi-agent system with comprehensive Maxim tracing. + +```python +import os +from dotenv import load_dotenv +from agno.agent import Agent +from agno.models.openai import OpenAIChat +from agno.tools.googlesearch import GoogleSearchTools +from agno.tools.yfinance import YFinanceTools +from maxim import Maxim +from maxim.logger.agno import instrument_agno + +# Load environment variables +load_dotenv() + +# Instrument Agno with Maxim +instrument_agno(Maxim().logger()) + +# Create individual agents +web_search_agent = Agent( + name="Web Agent", + role="Search the web for information", + model=OpenAIChat(id="gpt-4o"), + tools=[GoogleSearchTools()], + instructions="Always include sources", + show_tool_calls=True, + markdown=True, +) + +finance_agent = Agent( + name="Finance Agent", + role="Get financial data", + model=OpenAIChat(id="gpt-4o"), + tools=[YFinanceTools(stock_price=True, analyst_recommendations=True, company_info=True)], + instructions="Use tables to display data", + markdown=True, +) + +# Create multi-agent system +multi_ai_agent = Agent( + team=[web_search_agent, finance_agent], + model=OpenAIChat(id="gpt-4o"), + instructions="You are a helpful financial assistant. Answer user questions about stocks, companies, and financial data.", + show_tool_calls=True, + markdown=True +) + +# Use the multi-agent system +response = multi_ai_agent.run("What's the current stock price of Apple and what are the latest analyst recommendations?") +print(response.content) +``` + +![agno.gif](/images/maxim.gif) + +## Features + +### Observability & Tracing + +Maxim provides comprehensive observability for your Agno agents: + +- **Agent Tracing**: Track your agent's complete lifecycle, including tool calls, agent trajectories, and decision flows +- **Token Usage**: Monitor prompt and completion token consumption +- **Model Information**: Track which models are being used and their performance +- **Tool Calls**: Detailed logging of all tool executions and their results +- **Performance Metrics**: Latency, cost, and error rate tracking + +### Evaluation & Analytics + +- **Auto Evaluations**: Automatically evaluate captured logs based on filters and sampling +- **Human Evaluations**: Use human evaluation or rating to assess log quality +- **Node Level Evaluations**: Evaluate any component of your trace for detailed insights +- **Dashboards**: Visualize traces over time, usage metrics, latency & error rates + +### Alerting + +Set thresholds on error rates, cost, token usage, user feedback, and latency to get real-time alerts via Slack or PagerDuty. + +## Notes + +- **Environment Variables**: Ensure your environment variables are correctly set for the API key and repository ID. +- **Instrumentation Order**: Call `instrument_agno()` **before** creating or executing any agents to ensure proper tracing. +- **Debug Mode**: Enable debug mode to see detailed logging information: + + ```python + instrument_agno(Maxim().logger(), {"debug" : True}) + ``` +- **Maxim Docs**: For more information on Maxim's features and capabilities, refer to the [Maxim documentation](https://getmaxim.ai/docs). + +By following these steps, you can effectively integrate Agno with Maxim, enabling comprehensive observability, evaluation, and monitoring of your AI agents. \ No newline at end of file