|
| 1 | +--- |
| 2 | +title: 'Memori' |
| 3 | +description: 'Track and monitor Memori memory operations with AgentOps' |
| 4 | +--- |
| 5 | + |
| 6 | +[Memori](https://github.com/GibsonAI/memori) provides automatic short-term and long-term memory for AI applications and agents, seamlessly recording conversations and adding context to LLM interactions without requiring explicit memory management. |
| 7 | + |
| 8 | +## Why Track Memori with AgentOps? |
| 9 | + |
| 10 | +- **Memory Recording**: Track when conversations are automatically captured and stored |
| 11 | +- **Context Injection**: Monitor how memory is automatically added to LLM context |
| 12 | +- **Conversation Flow**: Understand the complete dialogue history across sessions |
| 13 | +- **Memory Effectiveness**: Analyze how historical context improves response quality |
| 14 | +- **Performance Impact**: Track latency and token usage from memory operations |
| 15 | +- **Error Tracking**: Identify issues with memory recording or context retrieval |
| 16 | + |
| 17 | +AgentOps automatically instruments Memori to provide complete observability of your memory operations. |
| 18 | + |
| 19 | +## Installation |
| 20 | + |
| 21 | +<CodeGroup> |
| 22 | +```bash pip |
| 23 | +pip install agentops memorisdk openai python-dotenv |
| 24 | +``` |
| 25 | + |
| 26 | +```bash poetry |
| 27 | +poetry add agentops memorisdk openai python-dotenv |
| 28 | +``` |
| 29 | + |
| 30 | +```bash uv |
| 31 | +uv pip install agentops memorisdk openai python-dotenv |
| 32 | +``` |
| 33 | +</CodeGroup> |
| 34 | + |
| 35 | +## Environment Configuration |
| 36 | + |
| 37 | +Load environment variables and set up API keys. |
| 38 | +<CodeGroup> |
| 39 | + ```bash Export to CLI |
| 40 | + export AGENTOPS_API_KEY="your_agentops_api_key_here" |
| 41 | + export OPENAI_API_KEY="your_openai_api_key_here" |
| 42 | + ``` |
| 43 | + ```txt Set in .env file |
| 44 | + AGENTOPS_API_KEY="your_agentops_api_key_here" |
| 45 | + OPENAI_API_KEY="your_openai_api_key_here" |
| 46 | + ``` |
| 47 | +</CodeGroup> |
| 48 | + |
| 49 | +## Tracking Automatic Memory Operations |
| 50 | + |
| 51 | +<CodeGroup> |
| 52 | +```python Basic Memory Tracking |
| 53 | +import agentops |
| 54 | +from memori import Memori |
| 55 | +from openai import OpenAI |
| 56 | + |
| 57 | +# Start a trace to group related operations |
| 58 | +agentops.start_trace("memori_conversation_flow", tags=["memori_memory_example"]) |
| 59 | + |
| 60 | +try: |
| 61 | + # Initialize OpenAI client |
| 62 | + openai_client = OpenAI() |
| 63 | + |
| 64 | + # Initialize Memori with conscious ingestion enabled |
| 65 | + # AgentOps tracks the memory configuration |
| 66 | + memori = Memori( |
| 67 | + database_connect="sqlite:///agentops_example.db", |
| 68 | + conscious_ingest=True, |
| 69 | + auto_ingest=True, |
| 70 | + ) |
| 71 | + |
| 72 | + memori.enable() |
| 73 | + |
| 74 | + # First conversation - AgentOps tracks LLM call and memory recording |
| 75 | + response1 = openai_client.chat.completions.create( |
| 76 | + model="gpt-4o-mini", |
| 77 | + messages=[ |
| 78 | + {"role": "user", "content": "I'm working on a Python FastAPI project"} |
| 79 | + ], |
| 80 | + ) |
| 81 | + |
| 82 | + print("Assistant:", response1.choices[0].message.content) |
| 83 | + |
| 84 | + # Second conversation - AgentOps tracks memory retrieval and context injection |
| 85 | + response2 = openai_client.chat.completions.create( |
| 86 | + model="gpt-4o-mini", |
| 87 | + messages=[{"role": "user", "content": "Help me add user authentication"}], |
| 88 | + ) |
| 89 | + |
| 90 | + print("Assistant:", response2.choices[0].message.content) |
| 91 | + print("💡 Notice: Memori automatically provided FastAPI project context!") |
| 92 | + |
| 93 | + # End trace - AgentOps aggregates all operations |
| 94 | + agentops.end_trace(end_state="success") |
| 95 | + |
| 96 | +except Exception as e: |
| 97 | + agentops.end_trace(end_state="error") |
| 98 | + |
| 99 | +``` |
| 100 | +</CodeGroup> |
| 101 | + |
| 102 | +## What You'll See in AgentOps |
| 103 | + |
| 104 | +When using Memori with AgentOps, your dashboard will show: |
| 105 | + |
| 106 | +1. **Conversation Timeline**: Complete flow of all conversations with memory context |
| 107 | +2. **Memory Injection Analytics**: Track when and how much context is automatically added |
| 108 | +3. **Context Relevance**: Monitor the effectiveness of automatic memory retrieval |
| 109 | +4. **Performance Metrics**: Latency impact of memory operations on LLM calls |
| 110 | +5. **Token Usage**: Track additional tokens consumed by memory context |
| 111 | +6. **Memory Growth**: Visualize how conversation history accumulates over time |
| 112 | +7. **Error Tracking**: Failed memory operations with full error context |
| 113 | + |
| 114 | +## Key Benefits of Memori + AgentOps |
| 115 | + |
| 116 | +- **Zero-Effort Memory**: Memori automatically handles conversation recording |
| 117 | +- **Intelligent Context**: Only relevant memory is injected into LLM context |
| 118 | +- **Complete Visibility**: AgentOps tracks all automatic memory operations |
| 119 | +- **Performance Monitoring**: Understand the cost/benefit of automatic memory |
| 120 | +- **Debugging Support**: Full traceability of memory decisions and context injection |
| 121 | + |
| 122 | +<script type="module" src="/scripts/github_stars.js"></script> |
| 123 | +<script type="module" src="/scripts/scroll-img-fadein-animation.js"></script> |
| 124 | +<script type="module" src="/scripts/button_heartbeat_animation.js"></script> |
| 125 | +<script type="module" src="/scripts/adjust_api_dynamically.js"></script> |
0 commit comments