1. Go to this page and download the library: Download dskripchenko/laravel-llm 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/ */
use Dskripchenko\Llm\Facades\Llm;
// From a preset (see docs/en/prompts-and-schemas.md)
$result = Llm::prompt(ClassifyArticle::class, ['body' => $article->description])
->about($article) // logged as the call's subject
->run();
$result->data; // ['type' => 'guide', 'level' => 2], validated
// By hand
$result = Llm::request('summarize')
->system('Summarize the article in two sentences.')
->user('Article:')
->data('article', $article->description) // untrusted text → a data block
->stream(function (string $delta): void { echo $delta; });
Llm::embed(['first text', 'second text'])->vectors;
Llm::rerank('query', $documents)->order();
Llm::fake(['article.classify' => ['type' => 'guide', 'level' => 2], 'summarize' => 'Short.']);
// … exercise your code …
Llm::assertPurpose('classify', 1);
Llm::assertSent(fn ($call) => $call->contains('To reset a password, open Settings', 'user'));
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.