1. Go to this page and download the library: Download latentkit/laravel 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/ */
latentkit / laravel example snippets
use LatentKit\LatentKit;
final class SummarizeReport
{
public function __construct(private readonly LatentKit $latentKit) {}
public function __invoke(string $report): string
{
$response = $this->latentKit->chat->create([
['role' => 'user', 'content' => 'Summarize this report: '.$report],
]);
return $response['content'];
}
}
use LatentKit\Laravel\Facades\LatentKit;
$context = LatentKit::client()->me->retrieveContext();
use Laravel\Ai\AnonymousAgent;
$response = (new AnonymousAgent(
instructions: 'Answer clearly and briefly.',
messages: [],
tools: [],
))->prompt(
'Summarize the deployment status.',
provider: 'latentkit',
);
echo $response->text;