From 41c0c86d828ebb0f7589c3f5f36c7dc9d386d356 Mon Sep 17 00:00:00 2001 From: Joakim Persson Date: Sat, 3 Aug 2024 00:52:55 +0200 Subject: [PATCH] =?UTF-8?q?Tog=20bort=20en=20on=C3=B6dig=20n=C3=A4stling?= =?UTF-8?q?=20av=20dictionary=20f=C3=B6r=20"models"?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- smartassist/src/startservices.py | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/smartassist/src/startservices.py b/smartassist/src/startservices.py index 6c8cf8c..38fe5da 100644 --- a/smartassist/src/startservices.py +++ b/smartassist/src/startservices.py @@ -73,26 +73,27 @@ def configure(): for endpoint in global_state.get_endpoints(): if endpoint["provider"] == "ollama": if "requestOptions" in endpoint: # Check if authentication is needed - # headers = { - # "Content-Type": "application/json", - # "Authorization": endpoint["requestOptions"]["headers"]["Authorization"] - # } headers = { + "Content-Type": "application/json", "Authorization": endpoint["requestOptions"]["headers"]["Authorization"] } + # headers = { + # "Authorization": endpoint["requestOptions"]["headers"]["Authorization"] + # } else: # otherwise proceed without authentication - # headers = {"Content-Type": "application/json"} - headers = None + headers = {"Content-Type": "application/json"} + # headers = None # models = tag(url = endpoint["url"], headers = headers) # Ask for models (LLMs) available at endpoint try: models = requests.get(endpoint["url"] + "/api/tags", headers=headers).json() + # models = requests.get(endpoint["url"] + "/api/tags", headers=headers) except requests.exceptions.RequestException as e: print(f"Error: {e}") if isinstance(models, dict) and 'error' in models: logger.error('Error fetching models from backend: %s', models['error']) else: - endpoint["models"] = models # Update endpoint with detected models + endpoint["models"] = models.get("models", []) # get the list of models directly logger.debug("models = \n{}".format(json.dumps(models, indent=4))) if endpoint["model"] is not "AUTODETECT": # Check if specified model is available # do something