<?php

namespace KupShop\LLMBundle\LlmProviders;

use GuzzleHttp\Psr7\Utils;
use KupShop\LLMBundle\Dto\TextPromptInput;
use Psr\Http\Message\StreamInterface;

class DummyDataLlmProvider extends AbstractLlmProvider
{
    public const LABEL = 'dummyData';
    private const DUMMY_TEXT = <<<EOT
    Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aliquam efficitur lacinia velit non fermentum. Sed tortor elit, faucibus sed 
    sodales congue, aliquet vitae libero. In quis volutpat risus. Aliquam auctor sem justo, id malesuada ipsum dignissim sit amet. Nulla 
    bibendum arcu eu ligula porttitor semper. Integer ut risus et tellus suscipit tempor at quis ex. Sed congue finibus sem in eleifend. 
    Duis justo est, ullamcorper tincidunt semper eu, ornare id turpis
    EOT;

    public function getResponse(TextPromptInput $prompt): string
    {
        sleep(3);

        return self::DUMMY_TEXT;
    }

    public function getStreamedResponse(TextPromptInput $prompt): StreamInterface
    {
        sleep(1);
        $i = 0;
        $stream = Utils::streamFor(function ($len) use (&$i) {
            usleep(100000);
            $i += $len;

            return substr(self::DUMMY_TEXT, $i - $len, $len) ?: false;
        });

        return $stream;
    }

    public function setModel(string $model): void
    {
        // Does not matter for dummy data
    }
}
