Lade till metod för att erhålla host_title för nuvarande endpoint

This commit is contained in:
2024-08-06 23:36:49 +02:00
parent 3f39e11b10
commit 942f9f78c9
+15 -2
View File
@@ -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.