Memori

Memori

AgentOps로 Memori 메모리 작업을 추적하고 모니터링하는 방법을 소개해요. Memori를 추적해야 하는 이유부터 설치, 자동 메모리 작업 추적 예제까지 알아볼게요.

출처: 문서

본문

Memori는 AI 애플리케이션과 에이전트를 위한 자동 단기·장기 메모리를 제공하며, 명시적인 메모리 관리를 요구하지 않고 대화를 원활하게 기록하고 LLM 상호작용에 컨텍스트를 추가합니다.

Memori를 AgentOps로 추적해야 하는 이유 (Why Track Memori with AgentOps?)

  • Memory Recording: 대화가 자동으로 캡처되고 저장되는 시점 추적
  • Context Injection: 메모리가 LLM 컨텍스트에 자동으로 추가되는 방식 모니터링
  • Conversation Flow: 세션 전반의 전체 대화 기록 이해
  • Memory Effectiveness: 과거 컨텍스트가 응답 품질을 어떻게 향상시키는지 분석
  • Performance Impact: 메모리 작업에서의 지연 시간과 토큰 사용량 추적
  • Error Tracking: 메모리 기록 또는 컨텍스트 조회 문제 식별

AgentOps는 Memori를 자동으로 계측해 메모리 작업에 대한 완전한 관측성을 제공합니다.

설치 (Installation)

```bash pip theme={null} pip install agentops memorisdk openai python-dotenv ```
poetry add agentops memorisdk openai python-dotenv
uv pip install agentops memorisdk openai python-dotenv

환경 설정 (Environment Configuration)

환경 변수를 로드하고 API 키를 설정하세요.

```bash Export to CLI theme={null} export AGENTOPS_API_KEY="your_agentops_api_key_here" export OPENAI_API_KEY="your_openai_api_key_here" ```
AGENTOPS_API_KEY="your_agentops_api_key_here"
OPENAI_API_KEY="your_openai_api_key_here"

자동 메모리 작업 추적 (Tracking Automatic Memory Operations)

```python Basic Memory Tracking theme={null} import agentops from memori import Memori from openai import OpenAI

agentops.start_trace("memori_conversation_flow", tags=["memori_memory_example"])

try: # Initialize OpenAI client openai_client = OpenAI()

  # Initialize Memori with conscious ingestion enabled
  # AgentOps tracks the memory configuration
  memori = Memori(
      database_connect="sqlite:///agentops_example.db",
      conscious_ingest=True,
      auto_ingest=True,
  )

  memori.enable()

  # First conversation - AgentOps tracks LLM call and memory recording
  response1 = openai_client.chat.completions.create(
      model="gpt-4o-mini",
      messages=[
          {"role": "user", "content": "I'm working on a Python FastAPI project"}
      ],
  )

  print("Assistant:", response1.choices[0].message.content)

  # Second conversation - AgentOps tracks memory retrieval and context injection
  response2 = openai_client.chat.completions.create(
      model="gpt-4o-mini",
      messages=[{"role": "user", "content": "Help me add user authentication"}],
  )

  print("Assistant:", response2.choices[0].message.content)
  print("💡 Notice: Memori automatically provided FastAPI project context!")

  # End trace - AgentOps aggregates all operations
  agentops.end_trace(end_state="success")

except Exception as e: agentops.end_trace(end_state="error")

</CodeGroup>

## AgentOps에서 볼 수 있는 것 (What You'll See in AgentOps)

Memori를 AgentOps와 함께 사용하면 대시보드에 다음이 표시됩니다.

1. **Conversation Timeline**: 메모리 컨텍스트를 포함한 모든 대화의 완전한 흐름
2. **Memory Injection Analytics**: 컨텍스트가 자동으로 추가되는 시점과 양 추적
3. **Context Relevance**: 자동 메모리 조회의 효과성 모니터링
4. **Performance Metrics**: LLM 호출에 대한 메모리 작업의 지연 시간 영향
5. **Token Usage**: 메모리 컨텍스트가 소비한 추가 토큰 추적
6. **Memory Growth**: 대화 기록이 시간에 따라 축적되는 방식 시각화
7. **Error Tracking**: 전체 오류 컨텍스트가 포함된 실패 메모리 작업

## Memori + AgentOps의 핵심 이점 (Key Benefits of Memori + AgentOps)

* **Zero-Effort Memory**: Memori는 대화 기록을 자동으로 처리
* **Intelligent Context**: 관련 메모리만 LLM 컨텍스트에 주입
* **Complete Visibility**: AgentOps는 모든 자동 메모리 작업을 추적
* **Performance Monitoring**: 자동 메모리의 비용/효과를 이해
* **Debugging Support**: 메모리 결정과 컨텍스트 주입의 완전한 추적 가능성

## 더 알아보기 (Learn more)

- [AgentOps 공식 문서](https://docs.agentops.ai/v2/integrations/memori)