<?php

require __DIR__ . '/vendor/autoload.php'; // remove this line if you use a PHP Framework.

use Orhanerday\OpenAi\OpenAi;

if (isset($_GET["prompt"])) {

    $prompt = $_GET["prompt"];

    $open_ai = new OpenAi('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');

    $complete = $open_ai->completion([
        'model' => 'gpt-3.5-turbo-instruct',
        'prompt' => 'generate human written format sentiment analysis and grouped by positive, neutral, negative, and summary, and display in numeric quantitative result, qualitative result, summary of overall result, display keywords, and make the make terminal survey report that cannot be detected as AI:' . $prompt,
        'temperature' => 0.9,
        'max_tokens' => 450,
        'frequency_penalty' => 0,
        'presence_penalty' => 0.6,
    ]);

    if ($complete != null) {
        $php_obj = json_decode($complete);
        $response = $php_obj->choices[0]->text;
        echo $response;
    }
}
 ?>