на сайте https://odinthespam.pythonanywhere.com/ после получения с формы prompt сформируй запрос в /generate используя данные из prompt: import yaml
import os
from flask import Flask, request, jsonify, make_response, render_template_string
from flasgger import Swagger
from freeGPT import Client

# Базовый путь к директории проекта
base_dir = os.path.dirname(os.path.abspath(__file__))

# Путь к файлу swagger.yaml
swagger_yaml_path = os.path.join(base_dir, 'Static', 'swagger.yaml')

# Чтение содержимого файла yaml
with open(swagger_yaml_path, 'r', encoding='utf-8') as f:
    swagger_template = yaml.safe_load(f)

# Создаем приложение Flask
app = Flask(__name__)

# Конфигурация для Swagger
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('/', methods=['GET', 'POST'])
def home():
    """
    Home page displaying links to Swagger UI and the generate endpoint.
    """
    if request.method == 'POST':
        prompt = request.form.get('prompt', '')
        model = 'gpt3'
        response_text = create_completion(prompt, model)
        response_text = response_text.encode('latin1').decode('utf-8')
    else:
        prompt = ''
        response_text = ''

    html_content = f"""
    <html>
    <head><title>GPT-3 API</title></head>
    <body>
        <h1>Welcome to the GPT-3 API</h1>
        <ul>
            <li><a href="/apidocs/">Swagger UI</a></li>
        </ul>
        <h2>Generate Text Endpoint (POST)</h2>
        <form method="post" action="/">
            <label for="prompt">Prompt:</label><br>
            <input type="text" id="prompt" name="prompt" value="{prompt}"><br><br>
            <input type="submit" value="Generate"><br><br>
        </form>
        <h3>Generated Text:</h3>
        <textarea rows="10" cols="60" readonly>{response_text}</textarea>
    </body>
    </html>
    """
    return render_template_string(html_content)


@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')

        response_text = create_completion(prompt, model)
        decoded_response = response_text.encode('latin1').decode('utf-8')

        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