前提条件
ZepTools 需要zep-cloud Python 包和 Zep API 密钥。
示例
以下示例演示了如何创建一个拥有 Zep 内存访问权限的智能体:cookbook/tools/zep_tools.py
Toolkit 参数
Toolkit 函数
Async Toolkit
ZepAsyncTools 类扩展了 ZepTools 类,并提供了工具函数的异步版本。
开发者资源
- 查看 Tools
- 查看 Cookbook
- 查看 Async Cookbook
Documentation Index
Fetch the complete documentation index at: /llms.txt
Use this file to discover all available pages before exploring further.
zep-cloud Python 包和 Zep API 密钥。
pip install zep-cloud
export ZEP_API_KEY=your_api_key
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(
model=OpenAIChat(),
tools=[zep_tools],
context={"memory": zep_tools.get_zep_memory(memory_type="context")},
add_context=True,
)
# 与智能体交互,使其了解用户
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.print_response("What do you know about me?")
| 参数 | 类型 | 默认值 | 描述 |
|---|---|---|---|
session_id | str | None | 可选的会话 ID。如果未提供,将自动生成。 |
user_id | str | None | 可选的用户 ID。如果未提供,将自动生成。 |
api_key | str | None | Zep API 密钥。如果未提供,则使用 ZEP_API_KEY 环境变量。 |
ignore_assistant_messages | bool | False | 添加到内存时是否忽略助手消息。 |
add_zep_message | bool | True | 向当前 Zep 会话内存添加消息。 |
get_zep_memory | bool | True | 为当前 Zep 会话检索内存。 |
search_zep_memory | bool | True | 在 Zep 内存存储中搜索相关信息。 |
instructions | str | None | 使用 Zep 工具的自定义说明。 |
add_instructions | bool | False | 是否添加默认说明。 |
| 函数 | 描述 |
|---|---|
add_zep_message | 向当前 Zep 会话内存添加消息。接受消息发送者的 role (str) 和消息文本的 content (str)。返回确认或错误消息。 |
get_zep_memory | 为当前 Zep 会话检索内存。接受可选的 memory_type (str) 参数,选项包括 “context” (默认)、“summary” 或 “messages”。返回请求的内存内容或错误。 |
search_zep_memory | 在 Zep 内存存储中搜索相关信息。接受 query (str) 以查找相关事实和可选的 search_scope (str) 参数,选项包括 “messages” (默认) 或 “summary”。返回搜索结果或错误消息。 |
ZepAsyncTools 类扩展了 ZepTools 类,并提供了工具函数的异步版本。