PHP code example of ndrstmr / steg-bundle

1. Go to this page and download the library: Download ndrstmr/steg-bundle library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

ndrstmr / steg-bundle example snippets


// config/bundles.php
return [
    // ...
    Steg\Bundle\StegBundle::class => ['all' => true],
];

use Steg\Client\InferenceClientInterface;
use Steg\Model\ChatMessage;

final class MyService
{
    public function __construct(
        private readonly InferenceClientInterface $steg,
    ) {}

    public function translate(string $text): string
    {
        $response = $this->steg->complete([
            ChatMessage::system('You are a translation assistant.'),
            ChatMessage::user($text),
        ]);

        return $response->content;
    }
}

use Steg\Client\InferenceClientInterface;
use Symfony\Component\DependencyInjection\Attribute\Autowire;

final class MyService
{
    public function __construct(
        #[Autowire(service: 'steg.client.vllm_local')]
        private readonly InferenceClientInterface $vllm,

        #[Autowire(service: 'steg.client.ollama_dev')]
        private readonly InferenceClientInterface $ollama,
    ) {}
}