1. Go to this page and download the library: Download php-llm/llm-chain-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/ */
php-llm / llm-chain-bundle example snippets
use PhpLlm\LlmChain\ChainInterface;
use PhpLlm\LlmChain\Model\Message\Message;
use PhpLlm\LlmChain\Model\Message\MessageBag;
final readonly class MyService
{
public function __construct(
private ChainInterface $chain,
) {
}
public function submit(string $message): string
{
$messages = new MessageBag(
Message::forSystem('Speak like a pirate.'),
Message::ofUser($message),
);
return $this->chain->call($messages);
}
}
use PhpLlm\LlmChain\Chain\Toolbox\Attribute\AsTool;
#[AsTool('company_name', 'Provides the name of your company')]
final class CompanyName
{
public function __invoke(): string
{
return 'ACME Corp.'
}
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.