{
  "openapi": "3.1.0",
  "info": {
    "title": "Python 服务接口",
    "description": "已实现的服务间接口。",
    "version": "0.1.0"
  },
  "servers": [
    {
      "url": "http://localhost:8000",
      "description": "本地开发"
    }
  ],
  "paths": {
    "/health": {
      "get": {
        "tags": [
          "基础"
        ],
        "summary": "检查 Python 服务",
        "operationId": "getPythonHealth",
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HealthResponse"
                },
                "example": {
                  "status": "ok",
                  "service": "python-api"
                }
              }
            }
          }
        },
        "security": []
      }
    },
    "/v1/moderation": {
      "post": {
        "tags": [
          "审核"
        ],
        "summary": "提交指定版本的内容审核",
        "description": "仅服务端调用。支持兼容 Chat Completions 的文本审核；未配置、含图片、异常或不通过均转人工。调用方负责版本和权限校验后保存结果。",
        "operationId": "reviewContent",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ReviewRequest"
              },
              "examples": {
                "review": {
                  "value": {
                    "content_id": "example",
                    "version": 1,
                    "text": "待审核内容"
                  }
                }
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ReviewResponse"
                },
                "example": {
                  "content_id": "example",
                  "version": 1,
                  "decision": "human",
                  "reason": "AI provider not configured; manual review required"
                }
              }
            }
          },
          "401": {
            "description": "服务令牌缺失或无效",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ServiceError"
                },
                "example": {
                  "detail": "Unauthorized"
                }
              }
            }
          },
          "503": {
            "description": "服务令牌未配置",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ServiceError"
                },
                "example": {
                  "detail": "Service authentication not configured"
                }
              }
            }
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                },
                "example": {
                  "detail": [
                    {
                      "loc": [
                        "body",
                        "version"
                      ],
                      "msg": "Field required",
                      "type": "missing"
                    }
                  ]
                }
              }
            }
          }
        },
        "security": [
          {
            "ServiceBearer": []
          }
        ]
      }
    }
  },
  "components": {
    "schemas": {
      "HTTPValidationError": {
        "properties": {
          "detail": {
            "items": {
              "$ref": "#/components/schemas/ValidationError"
            },
            "type": "array",
            "title": "Detail"
          }
        },
        "type": "object",
        "title": "HTTPValidationError"
      },
      "HealthResponse": {
        "properties": {
          "status": {
            "type": "string",
            "const": "ok",
            "title": "Status"
          },
          "service": {
            "type": "string",
            "const": "python-api",
            "title": "Service"
          }
        },
        "type": "object",
        "required": [
          "status",
          "service"
        ],
        "title": "HealthResponse"
      },
      "ProviderConfig": {
        "properties": {
          "base_url": {
            "type": "string",
            "maxLength": 2000,
            "title": "Base Url"
          },
          "model": {
            "type": "string",
            "maxLength": 200,
            "minLength": 1,
            "title": "Model"
          },
          "key": {
            "type": "string",
            "format": "password",
            "title": "Key",
            "writeOnly": true
          },
          "rules": {
            "type": "string",
            "maxLength": 10000,
            "minLength": 1,
            "title": "Rules"
          }
        },
        "type": "object",
        "required": [
          "base_url",
          "model",
          "key",
          "rules"
        ],
        "title": "ProviderConfig"
      },
      "ReviewRequest": {
        "properties": {
          "content_id": {
            "type": "string",
            "maxLength": 100,
            "minLength": 1,
            "title": "Content Id"
          },
          "version": {
            "type": "integer",
            "minimum": 1.0,
            "title": "Version"
          },
          "text": {
            "type": "string",
            "maxLength": 100000,
            "title": "Text"
          },
          "has_images": {
            "type": "boolean",
            "title": "Has Images",
            "default": false
          },
          "provider": {
            "anyOf": [
              {
                "$ref": "#/components/schemas/ProviderConfig"
              },
              {
                "type": "null"
              }
            ]
          }
        },
        "type": "object",
        "required": [
          "content_id",
          "version",
          "text"
        ],
        "title": "ReviewRequest"
      },
      "ReviewResponse": {
        "properties": {
          "content_id": {
            "type": "string",
            "title": "Content Id"
          },
          "version": {
            "type": "integer",
            "title": "Version"
          },
          "decision": {
            "type": "string",
            "enum": [
              "approve",
              "human"
            ],
            "title": "Decision"
          },
          "reason": {
            "type": "string",
            "title": "Reason"
          }
        },
        "type": "object",
        "required": [
          "content_id",
          "version",
          "decision",
          "reason"
        ],
        "title": "ReviewResponse"
      },
      "ServiceError": {
        "properties": {
          "detail": {
            "type": "string",
            "title": "Detail"
          }
        },
        "type": "object",
        "required": [
          "detail"
        ],
        "title": "ServiceError"
      },
      "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"
      }
    },
    "securitySchemes": {
      "ServiceBearer": {
        "type": "http",
        "scheme": "bearer"
      }
    }
  },
  "tags": [
    {
      "name": "基础"
    },
    {
      "name": "审核"
    }
  ]
}
