From cfed550a3e139e8638360ac6ce4dfbdbbf7b5fdf Mon Sep 17 00:00:00 2001 From: Joakim Persson Date: Thu, 1 Aug 2024 17:02:20 +0200 Subject: [PATCH] =?UTF-8?q?Lagt=20till=20backend=20och=20modules=20fr?= =?UTF-8?q?=C3=A5n=20yaml-filen?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- smartassist/src/utils.py | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/smartassist/src/utils.py b/smartassist/src/utils.py index ef1ee01..9fdcf9d 100644 --- a/smartassist/src/utils.py +++ b/smartassist/src/utils.py @@ -26,6 +26,11 @@ class GlobalState: cls._instance.logger.info(" __new__(cls): Logger in GlobalState created: %s", cls._instance.logger) cls._instance.llm = "phi3:mini" # Default LLM for queries. TODO: Check with ollama server that it actually exists cls._instance.backend_api_ep = "http://localhost:5005/api/chat" # Default backend API endpoint + # Try making things more aligned with the outline of the yaml file + cls._instance.backend = dict() # Holds info on which server the clients connect to + cls._instance.models = [] # A list that holds info on which models are available for use (server url, model name, provider et cetera) + # logging - already done in __new__, perhaps change layout later + return cls._instance def configure_logging(self, level=None): @@ -73,3 +78,20 @@ class GlobalState: """Getter for backend API endpoint""" return self.backend_api_ep + def set_backend(self, backend=None): + """Set backend that web clients connect to""" + self.backend = backend + + def get_backend(self): + """Getter for backend that web clients connect to""" + return self.backend + + def set_models(self, models=None): + """Set the list of models.""" + self.models = models + if not isinstance(models, list): + raise ValueError("Models must be a list") + + def get_models(self): + """Return the list of models""" + return self.models \ No newline at end of file