JsonStorage 类将本地 JSON 文件作为 Agent 的存储后端。
用法
json_storage_for_agent.py
参数
开发者资源
- 查看 Cookbook
Documentation Index
Fetch the complete documentation index at: /llms.txt
Use this file to discover all available pages before exploring further.
JsonStorage 类将本地 JSON 文件作为 Agent 的存储后端。
"""运行 `pip install duckduckgo-search openai` 来安装依赖。"""
from agno.agent import Agent
from agno.storage.json import JsonStorage
from agno.tools.duckduckgo import DuckDuckGoTools
agent = Agent(
storage=JsonStorage(dir_path="tmp/agent_sessions_json"),
tools=[DuckDuckGoTools()],
add_history_to_messages=True,
)
agent.print_response("How many people live in Canada?")
agent.print_response("What is their national anthem called?")
| 参数 | 类型 | 默认 | 描述 |
|---|---|---|---|
dir_path | str | - | 用于存储 JSON 文件的文件夹路径。 |