エージェントを Playground アプリケーションとしてホストします。Playground App は複数のエンドポイントを備えた FastAPI サーバを使用して、エージェント、チームとワークフローを稼働するために使用されます。
Agno : ユーザガイド : コンセプト : アプリケーション – Playground App
作成 : クラスキャット・セールスインフォメーション
作成日時 : 08/13/2025
バージョン : Agno 1.7.7
* 本記事は docs.agno.com の以下のページを独自に翻訳した上で、補足説明を加えてまとめ直しています :
* サンプルコードの動作確認はしておりますが、必要な場合には適宜、追加改変しています。
* ご自由にリンクを張って頂いてかまいませんが、sales-info@classcat.com までご一報いただけると嬉しいです。
Agno ユーザガイド : コンセプト : アプリケーション – Playground App
エージェントを Playground アプリケーションとしてホストします。
Playground App は (Agno Playground 上のエージェント、ワークフローとチームを管理し操作する) 複数のエンドポイントを備えた FastAPI サーバを使用して、エージェント、チームとワークフローを稼働するために使用されます。
使用例
エージェントを作成し、Playground でサービス提供します :
from agno.agent import Agent
from agno.memory.agent import AgentMemory
from agno.memory.db.postgres import PgMemoryDb
from agno.models.openai import OpenAIChat
from agno.playground import Playground
from agno.storage.postgres import PostgresStorage
db_url = "postgresql+psycopg://ai:ai@localhost:5532/ai"
basic_agent = Agent(
name="Basic Agent",
model=OpenAIChat(id="gpt-4o"), # Ensure OPENAI_API_KEY is set
memory=AgentMemory(
db=PgMemoryDb(
table_name="agent_memory",
db_url=db_url,
),
create_user_memories=True,
update_user_memories_after_run=True,
create_session_summary=True,
update_session_summary_after_run=True,
),
storage=PostgresStorage(
table_name="agent_sessions", db_url=db_url, auto_upgrade_schema=True
),
add_history_to_messages=True,
num_history_responses=3,
add_datetime_to_instructions=True,
markdown=True,
)
playground = Playground(
agents=[
basic_agent,
],
name="Basic Agent",
description="A playground for basic agent",
app_id="basic-agent",
)
app = playground.get_app()
if __name__ == "__main__":
playground.serve(app="basic:app", reload=True)
実行するには :
- PostgreSQL サーバが実行中で db_url 経由でアクセス可能であることを確認してください。
- OPENAI_API_KEY 環境変数を設定します。
- Playground UI は http://localhost:7777 で利用可能です。API docs は (設定で有効にされていれば) 通常は http://localhost:7777/docs にあります。
- Agent Playground により playground を使用してください。
コアコンポーネント
- Playground : Agno エージェント、チームやワークフローを API でラップします。
- Playground.serve : Uvicorn を使用して Playground FastAPI app をサービス提供します。
Playground クラスは Agno Playground アプリケーションを作成するための主要エントリポイントです。それは、Agent Playground や Agent UI により web インターフェイス経由でエージェント、チームやワークフローを簡単に公開することを可能にします。
以上