PHP code example of hameleon2x / llm-orchestra

1. Go to this page and download the library: Download hameleon2x/llm-orchestra 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/ */

    

hameleon2x / llm-orchestra example snippets



Hameleon2x\Llm\Dto\Request;
use Hameleon2x\Llm\Orchestra;
use Hameleon2x\Llm\Provider\OpenAiProvider;
use Hameleon2x\Llm\Registry;

$orchestra = new Orchestra(Registry::fromArray([
    'providers' => ['openai' => ['class' => OpenAiProvider::class, 'token' => 'sk-...']],
    'models'    => ['mini'   => ['provider' => 'openai', 'name' => 'gpt-4o-mini']],
    'defaultModel' => 'mini',
]));

$response = $orchestra->execute(Request::simple('Answer briefly.', 'What is PHP?'));

echo $response->isSuccess() ? $response->content : $response->error->category;
bash
php tests/run.php            # every suite
php tests/run.php Runner     # only suites and cases matching the filter