From adb056ced3e502fbd607baaa2ca2703f694f3d0c Mon Sep 17 00:00:00 2001 From: HowardChan Date: Wed, 11 Sep 2024 10:25:45 +0800 Subject: [PATCH] fix:error when adding the ollama embedding model (#8236) Co-authored-by: crazywoola <427733928@qq.com> --- .../ollama/text_embedding/text_embedding.py | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/api/core/model_runtime/model_providers/ollama/text_embedding/text_embedding.py b/api/core/model_runtime/model_providers/ollama/text_embedding/text_embedding.py index 60b85197be62d6..ffa9ea2f90791f 100644 --- a/api/core/model_runtime/model_providers/ollama/text_embedding/text_embedding.py +++ b/api/core/model_runtime/model_providers/ollama/text_embedding/text_embedding.py @@ -77,15 +77,10 @@ def _invoke( inputs.append(text) # Prepare the payload for the request - payload = { - "input": inputs, - "model": model, - } + payload = {"input": inputs, "model": model, "options": {"use_mmap": "true"}} - # Make the request to the OpenAI API - response = requests.post( - endpoint_url, headers=headers, data=json.dumps(payload), timeout=(10, 300), options={"use_mmap": "true"} - ) + # Make the request to the Ollama API + response = requests.post(endpoint_url, headers=headers, data=json.dumps(payload), timeout=(10, 300)) response.raise_for_status() # Raise an exception for HTTP errors response_data = response.json()