diff --git a/smartassist/src/startservices.py b/smartassist/src/startservices.py index f9ad800..1d64643 100644 --- a/smartassist/src/startservices.py +++ b/smartassist/src/startservices.py @@ -42,7 +42,7 @@ def configure(): return value def update_dict_with_env_vars(d): # Check all keys in d - for key in d: # Iterate over all keys in the dictionary. The keys seen are all at the same level + for key in d: # Iterate over all keys in the dictionary. The keys seen are all at the top-level of d logger.info(f"key investigated now: {key}") d[key] = update_value(d[key]) return d @@ -62,19 +62,29 @@ def configure(): # Extract and export backend API # endpoint as global state variable #################################### - if isinstance(updated_config.get('backend'), dict): # Look for 'backend' key - if isinstance(updated_config['backend'].get('url'), str): # Look for 'url' key - url = updated_config['backend'].get('url') - if isinstance(updated_config['backend'].get('api'), str): # Look for 'api' key - api = updated_config['backend'].get('api') - # backend_api_ep = url+api # Extract API endpoint if defined - logger.debug(f"Constructing endpoint address as url+api: {url+api}") - global_state.set_backend_api_ep(url+api) # Extract API endpoint if defined and set in global_state - logger.debug(f"Backend API endpoint is set to {global_state.get_backend_api_ep()}") + # if isinstance(updated_config.get('backend'), dict): # Look for 'backend' key + # if isinstance(updated_config['backend'].get('url'), str): # Look for 'url' key + # url = updated_config['backend'].get('url') + # if isinstance(updated_config['backend'].get('api'), str): # Look for 'api' key + # api = updated_config['backend'].get('api') + # # backend_api_ep = url+api # Extract API endpoint if defined + # logger.debug(f"Constructing endpoint address as url+api: {url+api}") + # global_state.set_backend_api_ep(url+api) # Extract API endpoint if defined and set in global_state + # logger.debug(f"Backend API endpoint is set to {global_state.get_backend_api_ep()}") #################################### # Extract models (server url, api_key, model, et cetera) #################################### + if isinstance(updated_config.get('backend'),dict): # Extract backend info from dictionary + global_state.set_backend(backend=updated_config.get('backend')) + logger.debug("backend = \n{}".format(json.dumps(global_state.get_backend(), indent=4))) + logger.debug(f"Backend API endpoint is set to: {global_state.get_backend_api_ep()}") + + if isinstance(updated_config.get('models'),list): # Extract info on model, url, provider et cetera from list + global_state.set_models(models=updated_config.get('models')) + logger.debug("models = \n{}".format(json.dumps(global_state.get_models(), indent=4))) + + # TODO: Remove this section when not needed anymore if isinstance(updated_config.get('ollama'), dict): # Look for 'ollama' key if isinstance(updated_config['ollama'].get('model'), str): # Look for 'model' key model_to_use = updated_config['ollama'].get('model') @@ -121,7 +131,6 @@ def start_backend(config): if __name__ == '__main__': conf = configure() # Read config from file and set up config dict - logger.debug('conf dictionary set to {}'.format(json.dumps(conf, indent=4))) + logger.debug('conf dictionary set to \n{}'.format(json.dumps(conf, indent=4))) # start_frontend(config=conf) # Not needed as we are using Flask for backend now start_backend(config=conf) -