From 252ee52c7c1c6e278d1a3e41610b15046380fd9d Mon Sep 17 00:00:00 2001
From: Christian Crawford <christian@spinsprire.com>
Date: Wed, 22 Jan 2025 14:34:54 -0500
Subject: [PATCH] Issue #3501534: Update embedding endpoint

---
 src/OllamaControlApi.php                 | 4 ++--
 src/Plugin/AiProvider/OllamaProvider.php | 2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/src/OllamaControlApi.php b/src/OllamaControlApi.php
index 13b66dc..f3aca32 100644
--- a/src/OllamaControlApi.php
+++ b/src/OllamaControlApi.php
@@ -62,8 +62,8 @@ class OllamaControlApi {
    *   The response.
    */
   public function embeddings($text, $model) {
-    $result = json_decode($this->makeRequest("api/embeddings", [], 'POST', [
-      'prompt' => $text,
+    $result = json_decode($this->makeRequest("api/embed", [], 'POST', [
+      'input' => $text,
       'model' => $model,
     ]), TRUE);
     return $result;
diff --git a/src/Plugin/AiProvider/OllamaProvider.php b/src/Plugin/AiProvider/OllamaProvider.php
index a7b9bb1..3fd8cbe 100644
--- a/src/Plugin/AiProvider/OllamaProvider.php
+++ b/src/Plugin/AiProvider/OllamaProvider.php
@@ -285,7 +285,7 @@ class OllamaProvider extends AiProviderClientBase implements
     }
     $response = $this->controlApi->embeddings($input, $model_id);
 
-    return new EmbeddingsOutput($response['embedding'], $response, []);
+    return new EmbeddingsOutput($response['embeddings'][0], $response, []);
   }
 
   /**
-- 
GitLab