1
0
cms11/app/Services/Ollama.php

25 lines
609 B
PHP

<?php
namespace App\Services;
use Illuminate\Support\Facades\Http;
class Ollama
{
/**
* Provides a description for specified image(s) using the llava model
* with ollama
*/
public static function describeImage(array $base64JpegImages)
{
$result = Http::throw()->timeout(240)->post(sprintf('%s/api/generate', env('OLLAMA_HOST')), [
'model' => 'llava',
'prompt' => 'Describe this image in a sentence or two',
'stream' => false,
'images' => $base64JpegImages,
])->json();
return $result['response'];
}
}