добавь содержимое swagger yaml: swagger: "2.0"
info:
  version: "1.0.0"
  title: "GPT-3 API"
  description: "API for generating text completions using GPT-3"
  termsOfService: "http://example.com/terms/"
  contact:
    name: "API Support"
    url: "http://www.example.com/support"
    email: "support@example.com"
  license:
    name: "Apache 2.0"
    url: "http://www.apache.org/licenses/LICENSE-2.0.html"
host: "localhost:5000"
basePath: "/"
schemes:
  - "http"
paths:
  /generate:
    post:
      summary: "Generate text completion"
      description: "Generate text completion using GPT-3 model based on the provided prompt."
      tags:
        - "Text generation"
      consumes:
        - "application/json"
      produces:
        - "application/json"
      parameters:
        - in: "body"
          name: "body"
          description: "JSON object containing the prompt and model"
          required: true
          schema:
            type: "object"
            required:
              - prompt
            properties:
              prompt:
                type: "string"
                example: "Explain quantum computing in simple terms."
              model:
                type: "string"
                default: "gpt3"
                example: "gpt3"
      responses:
        200:
          description: "Successful response"
          schema:
            type: "object"
            properties:
              response:
                type: "string"
                example: "Quantum computing is a type of computation that…"
        400:
          description: "Bad request. Client should check input parameters."
          schema:
            type: "object"
            properties:
              error:
                type: "string"
                example: "Invalid request parameters."
        500:
          description: "Internal server error"
          schema:
            type: "object"
            properties:
              error:
                type: "string"
                example: "An unexpected error occurred."
definitions:
  Error:
    type: "object"
    properties:
      error:
        type: "string"
        example: "An unexpected error occurred."в код from flask import Flask, request, jsonify, make_response
from flasgger import Swagger
from freeGPT import Client

# Создаем приложение Flask
app = Flask(__name__, static_url_path='/Static', static_folder='Static')

swagger_template = {
    "swagger": "2.0",
    "info": {
        "title": "GPT-3 API",
        "description": "API for generating text completions using GPT-3",
        "version": "1.0.0"
    },
    "host": "localhost:5000",
    "basePath": "/",
    "schemes": ["http"],
    "produces": ["application/json"],
    "consumes": ["application/json"],
}

swagger_config = {
    "headers": [],
    "specs": [
        {
            "endpoint": 'apispec_1',
            "route": '/apispec_1.json',  # Путь к спецификации JSON
            "rule_filter": lambda rule: True,  # Все эндпоинты включены
            "model_filter": lambda tag: True  # Все модели включены
        }
    ],
    "static_url_path": "/flasgger_static",
    "swagger_ui": True,
    "specs_route": "/apidocs/"
}

# Инициализация Swagger
swagger = Swagger(app, config=swagger_config, template=swagger_template)


def create_completion(prompt, model='gpt3'):
    # Используем библиотеку freeGPT для генерации текста
    return Client.create_completion(model, prompt)


@app.route('/generate', methods=['POST'])
def generate():
    """
    This is the text generation endpoint.
    Call this API passing a JSON body with 'prompt' and 'model' fields.
    —
    tags:
      - Text Generation
    parameters:
      - in: body
        name: body
        description: JSON object containing the prompt and model.
        required: true
        schema:
          type: object
          required:
            - prompt
          properties:
            prompt:
              type: string
              description: The text prompt to complete.
              example: "Пример текста"
            model:
              type: string
              description: The model to use, default is gpt3.
              default: "gpt3"
              example: "gpt3"
    responses:
      200:
        description: Text generated successfully
        schema:
          type: object
          properties:
            response:
              type: string
              description: The generated text.
      500:
        description: Internal server error
    """
    try:
        data = request.json
        prompt = data.get('prompt', '')
        model = data.get('model', 'gpt3')
        prompt = f"Ответь по-русски: {prompt}"

        response_text = create_completion(prompt, model)

        decoded_response = response_text.encode('latin1').decode('utf-8')

        # Создаем response с добавлением заголовков кеширования
        response = make_response(jsonify({'response': decoded_response.strip()}))
        response.headers['Cache-Control'] = 'no-store'
        response.headers['Pragma'] = 'no-cache'
        response.headers['Expires'] = '0'
        return response
    except Exception as e:
        return jsonify({'error': str(e)}), 500


if __name__ == "__main__":
    app.run(host='0.0.0.0', port=5000)