> ## Documentation Index
> Fetch the complete documentation index at: https://ikun.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Zep 记忆工具

## 代码

```python cookbook/tools/zep_tools.py theme={null}
import time
from agno.agent import Agent
from agno.models.openai import OpenAIChat
from agno.tools.zep import ZepTools

# 初始化 ZepTools
zep_tools = ZepTools(user_id="agno", session_id="agno-session", add_instructions=True)

# 初始化 Agent
agent = Agent(
    model=OpenAIChat(),
    tools=[zep_tools],
    context={"memory": zep_tools.get_zep_memory(memory_type="context")},
    add_context=True,
)

# 与 Agent 互动，以便它了解用户
agent.print_response("My name is John Billings")
agent.print_response("I live in NYC")
agent.print_response("I'm going to a concert tomorrow")

# 允许记忆与 Zep 数据库同步
time.sleep(10)

# 刷新上下文
agent.context["memory"] = zep_tools.get_zep_memory(memory_type="context")

# 询问 Agent 关于用户的信息
agent.print_response("What do you know about me?")
```

## 使用方法

<Steps>
  <Snippet file="create-venv-step.mdx" />

  <Step title="设置您的 API 密钥">
    ```bash theme={null}
    export OPENAI_API_KEY=xxx
    export ZEP_API_KEY=xxx
    ```
  </Step>

  <Step title="安装库">
    ```bash theme={null}
    pip install -U zep-cloud openai agno
    ```
  </Step>

  <Step title="运行 Agent">
    <CodeGroup>
      ```bash Mac theme={null}
      python cookbook/tools/zep_tools.py
      ```

      ```bash Windows theme={null}
      python cookbook/tools/zep_tools.py
      ```
    </CodeGroup>
  </Step>
</Steps>
