From 942f9f78c9eaf764d71406f237e519f521889847 Mon Sep 17 00:00:00 2001 From: Joakim Persson Date: Tue, 6 Aug 2024 23:36:49 +0200 Subject: [PATCH] =?UTF-8?q?Lade=20till=20metod=20f=C3=B6r=20att=20erh?= =?UTF-8?q?=C3=A5lla=20host=5Ftitle=20f=C3=B6r=20nuvarande=20endpoint?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- smartassist/src/utils.py | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/smartassist/src/utils.py b/smartassist/src/utils.py index c04b777..852979f 100644 --- a/smartassist/src/utils.py +++ b/smartassist/src/utils.py @@ -123,13 +123,26 @@ class GlobalState: def get_host_url(self) -> str: """ - Get the current URL of the host used for LLMs. + Get the URL of the host currently used for LLMs. Returns: - str: The current URL of the host. + str: The URL of the current host. """ return self.host_url + def get_host_title(self) -> str: + """ + Get the title of the host currently used for LLMs. + There must be a 1-to-1 mapping from host_url to host_title. + + Returns: + str: The title of the current host. + """ + endpoints = self.get_endpoints_with_key_value('url', self.get_host_url()) + if len(endpoints) != 1: + raise ValueError(f"Expected exactly one endpoint with url '{self.get_host_url()}', found {len(endpoints)}") + return endpoints[0]["title"] + def set_llm(self, model_name: str = "phi3:mini") -> None: """ Set the LLM to use for queries.