repositories
loading repo index
repositories
loading repo index
repository
loading code, commits, and activity
public Clawd ADK gateway launch mirror
stars
latest
clone command
git clone gitlawb://did:key:z6Mkq5mY...iFZ5/my-project-publ...git clone gitlawb://did:key:z6Mkq5mY.../my-project-publ...2fa351d6docs: add automaton and perps launch sources16d ago| #1 | --- |
| #2 | title: AgentOps |
| #3 | --- |
| #4 | |
| #5 | Integrate [**Mem0**](https://github.com/mem0ai/mem0) with [AgentOps](https://agentops.ai), a comprehensive monitoring and analytics platform for AI agents. This integration enables automatic tracking and analysis of memory operations, providing insights into agent performance and memory usage patterns. |
| #6 | |
| #7 | ## Overview |
| #8 | |
| #9 | 1. Automatic monitoring of Mem0 operations and performance metrics |
| #10 | 2. Real-time tracking of memory add, search, and retrieval operations |
| #11 | 3. Analytics dashboard with memory usage patterns and insights |
| #12 | 4. Error tracking and debugging capabilities for memory operations |
| #13 | |
| #14 | ## Prerequisites |
| #15 | |
| #16 | Before setting up Mem0 with AgentOps, ensure you have: |
| #17 | |
| #18 | 1. Installed the required packages: |
| #19 | ```bash |
| #20 | pip install mem0ai agentops python-dotenv |
| #21 | ``` |
| #22 | |
| #23 | 2. Valid API keys: |
| #24 | - [AgentOps API Key](https://app.agentops.ai/dashboard/api-keys) |
| #25 | - OpenAI API Key (for LLM operations) |
| #26 | - [Mem0 API Key](https://app.mem0.ai/dashboard/api-keys) (optional, for cloud operations) |
| #27 | |
| #28 | ## Basic Integration Example |
| #29 | |
| #30 | The following example demonstrates how to integrate Mem0 with AgentOps monitoring for comprehensive memory operation tracking: |
| #31 | |
| #32 | ```python |
| #33 | #Import the required libraries for local memory management with Mem0 |
| #34 | from mem0 import Memory, AsyncMemory |
| #35 | import os |
| #36 | import asyncio |
| #37 | import logging |
| #38 | from dotenv import load_dotenv |
| #39 | import agentops |
| #40 | import openai |
| #41 | |
| #42 | load_dotenv() |
| #43 | #Set up environment variables for API keys |
| #44 | os.environ["AGENTOPS_API_KEY"] = os.getenv("AGENTOPS_API_KEY") |
| #45 | os.environ["OPENAI_API_KEY"] = os.getenv("OPENAI_API_KEY") |
| #46 | |
| #47 | #Set up the configuration for local memory storage and define sample user data. |
| #48 | local_config = { |
| #49 | "llm": { |
| #50 | "provider": "openai", |
| #51 | "config": { |
| #52 | "model": "gpt-4.1-nano-2025-04-14", |
| #53 | "temperature": 0.1, |
| #54 | "max_tokens": 2000, |
| #55 | }, |
| #56 | } |
| #57 | } |
| #58 | user_id = "alice_demo" |
| #59 | agent_id = "assistant_demo" |
| #60 | run_id = "session_001" |
| #61 | |
| #62 | sample_messages = [ |
| #63 | {"role": "user", "content": "I'm planning to watch a movie tonight. Any recommendations?"}, |
| #64 | {"role": "assistant", "content": "How about a thriller? They can be quite engaging."}, |
| #65 | {"role": "user", "content": "I'm not a big fan of thriller movies but I love sci-fi movies."}, |
| #66 | { |
| #67 | "role": "assistant", |
| #68 | "content": "Got it! I'll avoid thriller recommendations and suggest sci-fi movies in the future.", |
| #69 | }, |
| #70 | ] |
| #71 | |
| #72 | sample_preferences = [ |
| #73 | "I prefer dark roast coffee over light roast", |
| #74 | "I exercise every morning at 6 AM", |
| #75 | "I'm vegetarian and avoid all meat products", |
| #76 | "I love reading science fiction novels", |
| #77 | "I work in software engineering", |
| #78 | ] |
| #79 | |
| #80 | #This function demonstrates sequential memory operations using the synchronous Memory class |
| #81 | def demonstrate_sync_memory(local_config, sample_messages, sample_preferences, user_id): |
| #82 | """ |
| #83 | Demonstrate synchronous Memory class operations. |
| #84 | """ |
| #85 | |
| #86 | agentops.start_trace("mem0_memory_example", tags=["mem0_memory_example"]) |
| #87 | try: |
| #88 | |
| #89 | memory = Memory.from_config(local_config) |
| #90 | |
| #91 | result = memory.add( |
| #92 | sample_messages, user_id=user_id, metadata={"category": "movie_preferences", "session": "demo"} |
| #93 | ) |
| #94 | |
| #95 | for i, preference in enumerate(sample_preferences): |
| #96 | result = memory.add(preference, user_id=user_id, metadata={"type": "preference", "index": i}) |
| #97 | |
| #98 | search_queries = [ |
| #99 | "What movies does the user like?", |
| #100 | "What are the user's food preferences?", |
| #101 | "When does the user exercise?", |
| #102 | ] |
| #103 | |
| #104 | for query in search_queries: |
| #105 | results = memory.search(query, user_id=user_id) |
| #106 | |
| #107 | if results and "results" in results: |
| #108 | for j, result in enumerate(results['results']): |
| #109 | print(f"Result {j+1}: {result.get('memory', 'N/A')}") |
| #110 | else: |
| #111 | print("No results found") |
| #112 | |
| #113 | all_memories = memory.get_all(user_id=user_id) |
| #114 | if all_memories and "results" in all_memories: |
| #115 | print(f"Total memories: {len(all_memories['results'])}") |
| #116 | |
| #117 | delete_all_result = memory.delete_all(user_id=user_id) |
| #118 | print(f"Delete all result: {delete_all_result}") |
| #119 | |
| #120 | agentops.end_trace(end_state="success") |
| #121 | except Exception as e: |
| #122 | agentops.end_trace(end_state="error") |
| #123 | |
| #124 | # Execute sync demonstrations |
| #125 | demonstrate_sync_memory(local_config, sample_messages, sample_preferences, user_id) |
| #126 | |
| #127 | ``` |
| #128 | |
| #129 | For detailed information on this integration, refer to the official [Agentops Mem0 integration documentation](https://docs.agentops.ai/v2/integrations/mem0). |
| #130 | |
| #131 | |
| #132 | ## Key Features |
| #133 | |
| #134 | ### 1. Automatic Operation Tracking |
| #135 | |
| #136 | AgentOps automatically monitors all Mem0 operations: |
| #137 | |
| #138 | - **Memory Operations**: Track add, search, get_all, delete operations and much more |
| #139 | - **Performance Metrics**: Monitor response times and success rates |
| #140 | - **Error Tracking**: Capture and analyze operation failures |
| #141 | |
| #142 | ### 2. Real-time Analytics Dashboard |
| #143 | |
| #144 | Access comprehensive analytics through the AgentOps dashboard: |
| #145 | |
| #146 | - **Usage Patterns**: Visualize memory usage trends over time |
| #147 | - **User Behavior**: Analyze how different users interact with memory |
| #148 | - **Performance Insights**: Identify bottlenecks and optimization opportunities |
| #149 | |
| #150 | ### 3. Session Management |
| #151 | |
| #152 | Organize your monitoring with structured sessions: |
| #153 | |
| #154 | - **Session Tracking**: Group related operations into logical sessions |
| #155 | - **Success/Failure Rates**: Track session outcomes for reliability monitoring |
| #156 | - **Custom Metadata**: Add context to sessions for better analysis |
| #157 | |
| #158 | ## Best Practices |
| #159 | |
| #160 | 1. **Initialize Early**: Always initialize AgentOps before importing Mem0 classes |
| #161 | 2. **Session Management**: Use meaningful session names and end sessions appropriately |
| #162 | 3. **Error Handling**: Wrap operations in try-catch blocks and report failures |
| #163 | 4. **Tagging**: Use tags to organize different types of memory operations |
| #164 | 5. **Environment Separation**: Use different projects or tags for dev/staging/prod |
| #165 | |
| #166 | <CardGroup cols={2}> |
| #167 | <Card title="CrewAI Integration" icon="users" href="/integrations/crewai"> |
| #168 | Monitor multi-agent CrewAI systems |
| #169 | </Card> |
| #170 | <Card title="LangChain Integration" icon="link" href="/integrations/langchain"> |
| #171 | Track LangChain agent performance |
| #172 | </Card> |
| #173 | </CardGroup> |
| #174 | |
| #175 |