{ "openapi": "3.1.0", "info": { "title": "Jyogi Navi API", "version": "0.1.0" }, "paths": { "/health": { "get": { "tags": [ "health" ], "summary": "Health Check", "description": "サービスの死活監視エンドポイント。", "operationId": "health_check_health_get", "responses": { "200": { "description": "Successful Response", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/HealthResponse" } } } } } } }, "/api/chat": { "post": { "tags": [ "chat" ], "summary": "Chat", "description": "Dify Chat API を呼び出してLLMの回答を返すエンドポイント。", "operationId": "chat_api_chat_post", "requestBody": { "content": { "application/json": { "schema": { "$ref": "#/components/schemas/ChatRequest" } } }, "required": true }, "responses": { "200": { "description": "Successful Response", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/ChatResponse" } } } }, "422": { "description": "Validation Error", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/HTTPValidationError" } } } } } } }, "/api/faq/search": { "get": { "tags": [ "faq" ], "summary": "Search Faq", "description": "FAQをキーワードで検索するエンドポイント(P0: LIKE検索)。", "operationId": "search_faq_api_faq_search_get", "parameters": [ { "name": "q", "in": "query", "required": true, "schema": { "type": "string", "minLength": 1, "maxLength": 200, "description": "検索キーワード", "title": "Q" }, "description": "検索キーワード" } ], "responses": { "200": { "description": "Successful Response", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/FaqSearchResponse" } } } }, "422": { "description": "Validation Error", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/HTTPValidationError" } } } } } } }, "/usage-logs": { "post": { "tags": [ "usage-logs" ], "summary": "Create Usage Log", "description": "チャットAPIから呼ばれるトークン消費ログ保存エンドポイント。", "operationId": "create_usage_log_usage_logs_post", "requestBody": { "content": { "application/json": { "schema": { "$ref": "#/components/schemas/UsageLogCreate" } } }, "required": true }, "responses": { "201": { "description": "Successful Response", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/UsageLogResponse" } } } }, "422": { "description": "Validation Error", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/HTTPValidationError" } } } } } } }, "/api/admin/stats": { "get": { "tags": [ "admin" ], "summary": "Get Admin Stats", "description": "管理ダッシュボード用KPI集計エンドポイント。", "operationId": "get_admin_stats_api_admin_stats_get", "responses": { "200": { "description": "Successful Response", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/AdminStatsResponse" } } } } } } } }, "components": { "schemas": { "AdminStatsResponse": { "properties": { "daily_questions": { "items": { "$ref": "#/components/schemas/DailyCount" }, "type": "array", "title": "Daily Questions" }, "total_tokens": { "type": "integer", "title": "Total Tokens" } }, "type": "object", "required": [ "daily_questions", "total_tokens" ], "title": "AdminStatsResponse" }, "ChatRequest": { "properties": { "session_id": { "type": "string", "maxLength": 128, "minLength": 1, "title": "Session Id" }, "message": { "type": "string", "maxLength": 5000, "minLength": 1, "title": "Message" } }, "type": "object", "required": [ "session_id", "message" ], "title": "ChatRequest", "description": "チャットリクエスト。" }, "ChatResponse": { "properties": { "answer": { "type": "string", "title": "Answer" }, "tokens_used": { "type": "integer", "title": "Tokens Used" } }, "type": "object", "required": [ "answer", "tokens_used" ], "title": "ChatResponse", "description": "チャットレスポンス。" }, "DailyCount": { "properties": { "day": { "type": "string", "format": "date", "title": "Day" }, "count": { "type": "integer", "title": "Count" } }, "type": "object", "required": [ "day", "count" ], "title": "DailyCount" }, "FaqSearchResponse": { "properties": { "results": { "items": { "$ref": "#/components/schemas/FaqSearchResult" }, "type": "array", "title": "Results" } }, "type": "object", "required": [ "results" ], "title": "FaqSearchResponse", "description": "FAQ検索レスポンス。" }, "FaqSearchResult": { "properties": { "content": { "type": "string", "title": "Content" } }, "type": "object", "required": [ "content" ], "title": "FaqSearchResult", "description": "FAQ検索結果の1件。" }, "HTTPValidationError": { "properties": { "detail": { "items": { "$ref": "#/components/schemas/ValidationError" }, "type": "array", "title": "Detail" } }, "type": "object", "title": "HTTPValidationError" }, "HealthResponse": { "properties": { "status": { "type": "string", "title": "Status" }, "db": { "type": "string", "title": "Db" } }, "type": "object", "required": [ "status", "db" ], "title": "HealthResponse" }, "UsageLogCreate": { "properties": { "session_id": { "type": "string", "minLength": 1, "title": "Session Id" }, "tokens": { "type": "integer", "minimum": 1.0, "title": "Tokens" }, "category": { "anyOf": [ { "type": "string" }, { "type": "null" } ], "title": "Category" } }, "type": "object", "required": [ "session_id", "tokens" ], "title": "UsageLogCreate", "description": "トークン消費ログ作成リクエスト。" }, "UsageLogResponse": { "properties": { "id": { "type": "string", "title": "Id" }, "session_id": { "type": "string", "title": "Session Id" }, "tokens": { "type": "integer", "title": "Tokens" }, "category": { "anyOf": [ { "type": "string" }, { "type": "null" } ], "title": "Category" }, "created_at": { "type": "string", "format": "date-time", "title": "Created At" } }, "type": "object", "required": [ "id", "session_id", "tokens", "category", "created_at" ], "title": "UsageLogResponse", "description": "トークン消費ログレスポンス。" }, "ValidationError": { "properties": { "loc": { "items": { "anyOf": [ { "type": "string" }, { "type": "integer" } ] }, "type": "array", "title": "Location" }, "msg": { "type": "string", "title": "Message" }, "type": { "type": "string", "title": "Error Type" }, "input": { "title": "Input" }, "ctx": { "type": "object", "title": "Context" } }, "type": "object", "required": [ "loc", "msg", "type" ], "title": "ValidationError" } } } }