I'm using their package, but would probably have used yours if it had streaming..
<?php
require __DIR__.'/vendor/autoload.php';
use JDecool\OllamaClient\ClientBuilder;
use JDecool\OllamaClient\Client\Message;
use JDecool\OllamaClient\Client\Request\ChatRequest;
$builder = new ClientBuilder();
$client = $builder->create('http://localhost:11434');
$request = new ChatRequest('phi3:mini', [
new Message('user', 'Why is the sky blue?'),
]);
// async
foreach ($client->chatStream($request) as $chunk) {
//var_dump($chunk);
$msg = $chunk->message;
echo $msg->content;
}
print "\n";
there's an implementation of using json-streaming over here: https://github.com/jdecool/ollama-php-client/blob/040ed0803e2b73bbc5e14b441e59c55bacfd0559/src/Client.php#L33 https://github.com/jdecool/ollama-php-client/blob/040ed0803e2b73bbc5e14b441e59c55bacfd0559/src/Client.php#L147 https://github.com/jdecool/ollama-php-client/blob/040ed0803e2b73bbc5e14b441e59c55bacfd0559/src/Http.php#L33
I'm using their package, but would probably have used yours if it had streaming..