new params for ollama client

This commit is contained in:
team2
2026-02-17 19:29:25 +01:00
parent ed8c20b032
commit 5b2a633a99

View File

@@ -36,7 +36,8 @@ final class OllamaClient
string $apiUrl, string $apiUrl,
string $model, string $model,
int $timeoutSeconds, int $timeoutSeconds,
) { )
{
$this->apiUrl = $apiUrl; $this->apiUrl = $apiUrl;
$this->model = $model; $this->model = $model;
$this->timeoutSeconds = $timeoutSeconds; $this->timeoutSeconds = $timeoutSeconds;
@@ -52,10 +53,19 @@ final class OllamaClient
*/ */
public function stream(string $prompt): Generator public function stream(string $prompt): Generator
{ {
$json = [];
$payload = json_encode([ $payload = json_encode([
'model' => $this->model, 'model' => $this->model,
'prompt' => $prompt, 'prompt' => $prompt,
'stream' => true, 'stream' => true,
'options' => [
"temperature" => 0.9,
"top_k" => 35,
"top_p" => 0.9,
"repeat_penalty" => 1.1,
"num_ctx" => 8192
]
], JSON_THROW_ON_ERROR); ], JSON_THROW_ON_ERROR);
$buffer = ''; $buffer = '';
@@ -135,7 +145,7 @@ final class OllamaClient
} }
} }
if(!$json['response']){ if (!isset($json['response'])) {
yield $json; yield $json;
return; return;
} }