Skip to content

Commit 63bc0da

Browse files
added checks for invalid model setting
1 parent a23055d commit 63bc0da

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

src/Agents/Adapters/Ollama.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,10 @@ public function __construct(
3939
string $model = self::MODEL_EMBEDDING_GEMMA,
4040
int $timeout = 90
4141
) {
42+
if (! in_array($model, self::MODELS, true)) {
43+
throw new \InvalidArgumentException("Invalid model: {$model}. Supported models: ".implode(', ', self::MODELS));
44+
}
45+
4246
$this->model = $model;
4347
$this->setTimeout($timeout);
4448
}
@@ -123,6 +127,9 @@ public function getEmbeddingDimension(): int
123127
*/
124128
public function setModel(string $model): self
125129
{
130+
if (! in_array($model, self::MODELS, true)) {
131+
throw new \InvalidArgumentException("Invalid model: {$model}. Supported models: ".implode(', ', self::MODELS));
132+
}
126133
$this->model = $model;
127134

128135
return $this;

0 commit comments

Comments
 (0)