Skip to content

Wire demo(ローカルブラウザ UI)

言語: 日本語 | English | 简体中文 | 四川话

FastAPI がチャット UI を提供し、ブラウザが Agent.arun_wire()application/x-ndjson ストリームを消費します。

GitHub Pages ではデモは動きません

公開サイトは静的ドキュメントのみ。体験するにはローカルでサーバーを起動してください。

画面プレビュー

pagent wire demo — チャット・推論・Wire ログ

ストリーミング応答、推論ブロック、Wire ログドロワー(arun_wire() の JSON-RPC 行)。

アーキテクチャ

コンポーネント

ブラウザとサーバー

FastAPI 内部

Agent.arun_wire、ツール、セッション 小帕

GET /index.html を配信。ブラウザは各行の method + params を UI / ドロワー用にパースします。

部分ファイル役割
SPAstatic/index.htmlfetch("/api/chat")、NDJSON 行を描画
APIserver.pyagent.arun_wire(message)StreamingResponse
ライブラリpagentAgent ループ、Wire シリアライズ(プロトコル

リクエストごとに 新しい Agent(デモ用の簡略化。本番はユーザーごとに session を再利用)。

リクエストの流れ

ターンや ToolResultRunEnd も同じ A-->>UI の流れ(イベント 参照)。停止は fetch の AbortController — Wire の method ではありません。

停止

Wire にキャンセル methodなし — HTTP ストリームを閉じて停止。

起動

例は uv run を使用。uv が初めての方は 公式ドキュメント を参照。

bash
git clone https://github.com/SyncLionPaw/pagent.git
cd pagent
export DEEPSEEK_API_KEY="your-key"

uv run --with fastapi --with uvicorn python examples/wire_browser/server.py

ブラウザで http://127.0.0.1:8765

停止

  • サーバー: ターミナルで Ctrl+C
  • 生成中: UI の 停止(HTTP リクエストを中断)

内容

  • チャット UI、ツールカード、思考ブロック(任意)
  • サイドドロワーで生の Wire NDJSON
  • Wire プロトコル と同じメッセージ体系

ソース: examples/wire_browser/

Released under the MIT License.