1. Go to this page and download the library: Download knackline/laravel-olm 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/ */
knackline / laravel-olm example snippets
use Illuminate\Foundation\DevCommands;
DevCommands::except('olm');
foreach (Olm::streamChat([
['role' => 'user', 'content' => 'Write a haiku'],
]) as $token) {
echo $token;
}
$embedding = Olm::embed('hello world');
$vector = $embedding->first();
$completion = Olm::complete('Once upon a time');
$models = Olm::models();
// Ollama only
Olm::driver('ollama')->pull('llama3.2');
$info = Olm::driver('ollama')->show('llama3.2');
use Knackline\Olm\OlmManager;
class ChatController
{
public function __construct(protected OlmManager $olm)
{
}
public function __invoke()
{
return $this->olm->chat([
['role' => 'user', 'content' => 'Hi'],
]);
}
}