GuardRail

GuardRail · Actions GPT

OpenAI Data Analysis & Guiderails Script

This API provides advanced data analysis and conditional completions using OpenAI's GPT models. Key features include sentiment analysis, content classification, trend analysis, and the ability to specify different GPT models for tailored text generation and analysis. The script ensures high-quality, context-sensitive AI-generated text, making it ideal for various applications such as content moderation, customer support, and market research.

  • POST /completions/Completions
  • POST /analysis/Perform Analysis
  • GET /analysis_typesAnalysis Types
  • POST /conditional_analysis/Conditional Analysis

    Perform conditional analysis with multiple conditions. This endpoint analyzes the given request data and checks whether it meets all specified conditions.

Schéma original API
{
  "openapi": "3.1.0",
  "info": {
    "title": "OpenAI Data Analysis & Guiderails Script",
    "description": "This API provides advanced data analysis and conditional completions using OpenAI's GPT models. Key features include sentiment analysis, content classification, trend analysis, and the ability to specify different GPT models for tailored text generation and analysis. The script ensures high-quality, context-sensitive AI-generated text, making it ideal for various applications such as content moderation, customer support, and market research.",
    "version": "0.0.1"
  },
  "paths": {
    "/completions/": {
      "post": {
        "tags": [
          "Completions"
        ],
        "summary": "Completions",
        "operationId": "Completions",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CompletionRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {}
              }
            }
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        },
        "security": [
          {
            "HTTPBearer": []
          }
        ]
      }
    },
    "/analysis/": {
      "post": {
        "tags": [
          "Perform Analysis"
        ],
        "summary": "Perform Analysis",
        "operationId": "Perform Analysis",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/AnalysisRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AnalysisResult"
                }
              }
            }
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        },
        "security": [
          {
            "HTTPBearer": []
          }
        ]
      }
    },
    "/analysis_types": {
      "get": {
        "tags": [
          "Analysis Types"
        ],
        "summary": "Analysis Types",
        "operationId": "Analysis Types",
        "parameters": [
          {
            "name": "query",
            "in": "query",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "type": "string"
                },
                {
                  "type": "null"
                }
              ],
              "description": "Keyword for fuzzy search",
              "title": "Query"
            },
            "description": "Keyword for fuzzy search"
          }
        ],
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AnalysisTypesResponse"
                }
              }
            }
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        }
      }
    },
    "/conditional_analysis/": {
      "post": {
        "tags": [
          "Conditional Analysis"
        ],
        "summary": "Conditional Analysis",
        "description": "Perform conditional analysis with multiple conditions. This endpoint analyzes the given request data and checks whether it meets all specified conditions.",
        "operationId": "Conditional Analysis",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CombinedRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AnalysisResult"
                }
              }
            }
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        },
        "security": [
          {
            "HTTPBearer": []
          }
        ]
      }
    }
  },
  "components": {
    "schemas": {
      "AnalysisRequest": {
        "properties": {
          "analysis_type": {
            "type": "string",
            "title": "Analysis Type",
            "default": "sentiment_analysis",
            "example": "sentiment_analysis"
          },
          "messages": {
            "items": {
              "$ref": "#/components/schemas/Message"
            },
            "type": "array",
            "title": "Messages",
            "default": [
              {
                "role": "user",
                "content": "I feel incredibly happy and content today!"
              }
            ],
            "example": [
              {
                "content": "I feel incredibly happy and content today!",
                "role": "user"
              }
            ]
          },
          "token_limit": {
            "type": "integer",
            "title": "Token Limit",
            "default": 1000,
            "example": 1000
          },
          "top_p": {
            "type": "number",
            "title": "Top P",
            "default": 0.9,
            "example": 0.1
          },
          "temperature": {
            "type": "number",
            "title": "Temperature",
            "default": 0,
            "example": 0
          }
        },
        "type": "object",
        "title": "AnalysisRequest"
      },
      "AnalysisResult": {
        "properties": {
          "analysis": {
            "type": "string",
            "title": "Analysis"
          },
          "details": {
            "type": "object",
            "title": "Details"
          },
          "error": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Error"
          },
          "raw_openai_response": {
            "anyOf": [
              {
                "type": "object"
              },
              {
                "type": "null"
              }
            ],
            "title": "Raw Openai Response"
          }
        },
        "type": "object",
        "required": [
          "analysis",
          "details",
          "error"
        ],
        "title": "AnalysisResult"
      },
      "AnalysisTypeDetail": {
        "properties": {
          "type": {
            "type": "string",
            "title": "Type"
          },
          "json_schema": {
            "type": "object",
            "title": "Json Schema"
          },
          "example_request": {
            "type": "object",
            "title": "Example Request"
          }
        },
        "type": "object",
        "required": [
          "type",
          "json_schema",
          "example_request"
        ],
        "title": "AnalysisTypeDetail"
      },
      "AnalysisTypesResponse": {
        "properties": {
          "analysis_types": {
            "additionalProperties": {
              "$ref": "#/components/schemas/AnalysisTypeDetail"
            },
            "type": "object",
            "title": "Analysis Types"
          }
        },
        "type": "object",
        "required": [
          "analysis_types"
        ],
        "title": "AnalysisTypesResponse"
      },
      "CombinedRequest": {
        "properties": {
          "request_data": {
            "$ref": "#/components/schemas/AnalysisRequest"
          },
          "conditions": {
            "items": {
              "$ref": "#/components/schemas/Condition"
            },
            "type": "array",
            "title": "Conditions"
          }
        },
        "type": "object",
        "required": [
          "request_data",
          "conditions"
        ],
        "title": "CombinedRequest"
      },
      "CompletionRequest": {
        "properties": {
          "model": {
            "type": "string",
            "title": "Model",
            "default": "gpt-3.5-turbo-1106"
          },
          "temperature": {
            "type": "number",
            "title": "Temperature",
            "default": 0
          },
          "max_tokens": {
            "type": "integer",
            "title": "Max Tokens",
            "default": 1000
          },
          "top_p": {
            "type": "number",
            "title": "Top P",
            "default": 0.1
          },
          "frequency_penalty": {
            "type": "number",
            "title": "Frequency Penalty",
            "default": 0
          },
          "presence_penalty": {
            "type": "number",
            "title": "Presence Penalty",
            "default": 0
          },
          "messages": {
            "items": {
              "$ref": "#/components/schemas/Message"
            },
            "type": "array",
            "title": "Messages"
          },
          "n": {
            "type": "integer",
            "title": "N",
            "default": 1
          },
          "stream": {
            "type": "boolean",
            "title": "Stream",
            "default": false
          }
        },
        "type": "object",
        "required": [
          "messages"
        ],
        "title": "CompletionRequest"
      },
      "Condition": {
        "properties": {
          "analysis_type": {
            "type": "string",
            "title": "Analysis Type"
          },
          "key": {
            "type": "string",
            "title": "Key"
          },
          "threshold": {
            "anyOf": [
              {
                "type": "number"
              },
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Threshold"
          },
          "condition_type": {
            "type": "string",
            "enum": [
              "greater",
              "less",
              "equal",
              "contains",
              "exists",
              "is_type",
              "length_greater",
              "length_less",
              "length_equal",
              "nested_contains",
              "regex_match",
              "key_value_pair"
            ],
            "title": "Condition Type"
          }
        },
        "type": "object",
        "required": [
          "analysis_type",
          "key",
          "threshold",
          "condition_type"
        ],
        "title": "Condition"
      },
      "HTTPValidationError": {
        "properties": {
          "detail": {
            "items": {
              "$ref": "#/components/schemas/ValidationError"
            },
            "type": "array",
            "title": "Detail"
          }
        },
        "type": "object",
        "title": "HTTPValidationError"
      },
      "Message": {
        "properties": {
          "role": {
            "type": "string",
            "title": "Role"
          },
          "content": {
            "type": "string",
            "title": "Content"
          }
        },
        "type": "object",
        "required": [
          "role",
          "content"
        ],
        "title": "Message"
      },
      "ValidationError": {
        "properties": {
          "loc": {
            "items": {
              "anyOf": [
                {
                  "type": "string"
                },
                {
                  "type": "integer"
                }
              ]
            },
            "type": "array",
            "title": "Location"
          },
          "msg": {
            "type": "string",
            "title": "Message"
          },
          "type": {
            "type": "string",
            "title": "Error Type"
          }
        },
        "type": "object",
        "required": [
          "loc",
          "msg",
          "type"
        ],
        "title": "ValidationError"
      }
    },
    "securitySchemes": {
      "HTTPBearer": {
        "type": "http",
        "scheme": "bearer"
      }
    }
  },
  "servers": [
    {
      "url": "https://guardrail.ruv.io",
      "description": "Production server"
    }
  ]
}