Files
playchat/docs/api.md
colcaroliandClaude Opus 5 a08b1785a4 Add shared notes with tabbed pages editable by user and AI
Adds a note_pages table backing a tabbed notes panel where the user and
the model can both read and write. Only page titles (plus a short
preview) are injected into the system prompt on every turn; full page
content is kept out of context and fetched on demand via a read_note
tool, with write_note letting the model append to, replace, or create a
page.

Generalizes llm.resolve_web_search into resolve_tool_calls so the
tool-calling loop handles web_search and the new note tools through one
path. The chat stream emits a notes_updated SSE event when the model
edits a note so the frontend panel can refresh; local edits are tracked
as dirty and never clobbered by that refresh.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-08-19 01:27:31 +09:00

3.8 KiB
Raw Permalink Blame History

API リファレンス

ベースURL: http://localhost:8000
Swagger UI: http://localhost:8000/docs


チャット

POST /chat/stream

SSE でストリーミング応答を返す。

リクエストボディ

{
  "message": "こんにちは",
  "session_id": "uuid(省略時は新規セッション作成)",
  "model": "gpt-5.4(省略時は DEFAULT_MODEL)"
}

SSE イベント

type value タイミング
session_id セッション UUID 新規セッション作成直後
chunk テキスト断片 LLM トークン生成ごと
notes_updated — AI が共有ノートを書き換えた直後
done — 正常完了
error エラーメッセージ 例外発生時

GET /chat/sessions

セッション一覧を updated_at 降順で返す。

レスポンス

[
  {
    "id": "uuid",
    "title": "セッションタイトル",
    "model": "gpt-5.4",
    "updated_at": "2026-06-01T12:00:00"
  }
]

GET /chat/sessions/{session_id}/messages

セッションのメッセージ一覧を created_at 昇順で返す。

レスポンス

[
  { "id": 1, "role": "user", "content": "...", "created_at": "..." },
  { "id": 2, "role": "assistant", "content": "...", "created_at": "..." }
]

DELETE /chat/sessions/{session_id}

セッションと紐づくメッセージ・メモリをすべて削除。204 No Content を返す。


メモリ

GET /memory/{session_id}

セッションの長期メモリ(要約)一覧を created_at 昇順で返す。

レスポンス

[
  {
    "id": 1,
    "session_id": "uuid",
    "summary": "要約テキスト",
    "created_at": "2026-06-01T12:00:00"
  }
]

DELETE /memory/{memory_id}

特定のメモリエントリを削除。204 No Content を返す。


共有ノート

ユーザーと AI が共同編集するノート。ページのタイトル一覧は毎回システムプロンプトに注入され、 本文は AI が read_note / write_note ツールで読み書きする。

GET /api/notes

全ページを position 昇順で返す。

レスポンス

[
  {
    "id": 1,
    "title": "買い物リスト",
    "content": "- 牛乳
- 卵",
    "position": 0,
    "updated_at": "2026-08-19T12:00:00"
  }
]

POST /api/notes

ページを新規作成し、201 Created で作成したページを返す。

リクエスト

{ "title": "新しいページ", "content": "" }

PATCH /api/notes/{page_id}

ページのタイトル・本文を更新する。指定したフィールドだけが変更される。 タイトルを空文字にしようとした場合は 400、ページが存在しない場合は 404 を返す。

リクエスト

{ "content": "更新後の本文" }

DELETE /api/notes/{page_id}

ページを削除。204 No Content を返す。


ログ

GET /logs

LLM API 呼び出しログを created_at 降順で返す。

クエリパラメーター

パラメーター 型 説明
session_id string セッションで絞り込み
status ok / error 成功・失敗で絞り込み
limit int (≤500) 最大件数(デフォルト 100)
offset int スキップ件数

レスポンス

[
  {
    "id": 1,
    "session_id": "uuid",
    "model": "gpt-5.4",
    "request_json": "[{\"role\":\"user\",\"content\":\"...\"}]",
    "response_text": "...",
    "error": null,
    "latency_ms": 832.5,
    "created_at": "2026-06-01T12:00:00"
  }
]

DELETE /logs/{log_id}

指定ログを削除。204 No Content を返す。


ヘルスチェック

GET /health

{ "status": "ok" }