<?php

namespace RistrettoApps\Spawnster\Services;

class GenerateDescription
{
    /**
     * Handle the OpenAI request for generate website description.
     * 
     * @param  mixed  $request
     * @return bool|string|null
     *
     * @since 1.0.0
     */
    public function handle(mixed $request)
    {
        if (!$request) {
            return null;
        }

        $openAiService = new OpenAiService();
        $language_instruction = $openAiService->get_language_instruction();
        $openAiService->content = 'Write a short description regarding ' . $request . $language_instruction;

        return $openAiService->getResponse();
    }
}