File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -23,6 +23,10 @@ class Ollama extends Adapter
2323 */
2424 protected int $ timeout ;
2525
26+ private string $ endpoint = 'http://ollama:11434/api/embed ' ;
27+
28+ public const MODELS = [self ::MODEL_EMBEDDING_GEMMA ];
29+
2630 /**
2731 * Create a new Ollama adapter (no API key required for local call)
2832 *
@@ -60,7 +64,7 @@ public function embed(string $text): array
6064 'input ' => $ text ,
6165 ];
6266 $ response = $ client ->fetch (
63- ' http://ollama:11434/api/embed ' ,
67+ $ this -> getEndpoint () ,
6468 Client::METHOD_POST ,
6569 $ payload
6670 );
@@ -84,7 +88,7 @@ public function embed(string $text): array
8488 */
8589 public function getModels (): array
8690 {
87- return [ self ::MODEL_EMBEDDING_GEMMA ] ;
91+ return self ::MODELS ;
8892 }
8993
9094 /**
@@ -159,6 +163,29 @@ protected function formatErrorMessage($json): string
159163 return '(ollama_error) ' .$ msg ;
160164 }
161165
166+ /**
167+ * Get the API endpoint
168+ *
169+ * @return string
170+ */
171+ public function getEndpoint (): string
172+ {
173+ return $ this ->endpoint ;
174+ }
175+
176+ /**
177+ * Set the API endpoint
178+ *
179+ * @param string $endpoint
180+ * @return self
181+ */
182+ public function setEndpoint (string $ endpoint ): self
183+ {
184+ $ this ->endpoint = $ endpoint ;
185+
186+ return $ this ;
187+ }
188+
162189 public function getSupportForEmbeddings (): bool
163190 {
164191 return true ;
You can’t perform that action at this time.
0 commit comments