fix unused config for model
This commit is contained in:
@@ -14,11 +14,11 @@ use Throwable;
|
||||
final class OllamaClient
|
||||
{
|
||||
private ?ModelGenerationConfig $cachedConfig = null;
|
||||
private $config = null;
|
||||
|
||||
public function __construct(
|
||||
private string $apiUrl,
|
||||
private string $model,
|
||||
private int $timeoutSeconds,
|
||||
private string $timeoutSeconds,
|
||||
private ModelGenerationConfigProvider $configProvider
|
||||
) {}
|
||||
|
||||
@@ -27,9 +27,9 @@ final class OllamaClient
|
||||
*/
|
||||
public function stream(string $prompt): Generator
|
||||
{
|
||||
$config = $this->getConfig();
|
||||
$this->config = $this->getConfig();
|
||||
|
||||
if ($config->isStream()) {
|
||||
if ($this->config->isStream()) {
|
||||
yield from $this->streamInternal($prompt);
|
||||
return;
|
||||
}
|
||||
@@ -166,7 +166,7 @@ final class OllamaClient
|
||||
private function buildPayload(string $prompt, bool $stream): string
|
||||
{
|
||||
return json_encode([
|
||||
'model' => $this->model,
|
||||
'model' => $this->config->getModelName(),
|
||||
'prompt' => $prompt,
|
||||
'stream' => $stream,
|
||||
'options' => $this->buildOptions()
|
||||
@@ -178,14 +178,13 @@ final class OllamaClient
|
||||
*/
|
||||
private function buildOptions(): array
|
||||
{
|
||||
$config = $this->getConfig();
|
||||
|
||||
$this->config = $this->getConfig();
|
||||
return [
|
||||
'temperature' => $config->getTemperature(),
|
||||
'top_k' => $config->getTopK(),
|
||||
'top_p' => $config->getTopP(),
|
||||
'repeat_penalty' => $config->getRepeatPenalty(),
|
||||
'num_ctx' => $config->getNumCtx(),
|
||||
'temperature' => $this->config->getTemperature(),
|
||||
'top_k' => $this->config->getTopK(),
|
||||
'top_p' => $this->config->getTopP(),
|
||||
'repeat_penalty' => $this->config->getRepeatPenalty(),
|
||||
'num_ctx' => $this->config->getNumCtx(),
|
||||
];
|
||||
}
|
||||
|
||||
@@ -195,7 +194,7 @@ final class OllamaClient
|
||||
private function getConfig(): ModelGenerationConfig
|
||||
{
|
||||
if ($this->cachedConfig === null) {
|
||||
$this->cachedConfig = $this->configProvider->getActiveForModel($this->model);
|
||||
$this->cachedConfig = $this->configProvider->getActiveForModel();
|
||||
}
|
||||
|
||||
return $this->cachedConfig;
|
||||
|
||||
Reference in New Issue
Block a user