diff --git a/smartassist/src/backend.py b/smartassist/src/backend.py index 39a7e4f..17ad2b3 100644 --- a/smartassist/src/backend.py +++ b/smartassist/src/backend.py @@ -7,11 +7,16 @@ import requests import json import logging import os -# from utils import set_local_logger +import utils +from utils import GlobalState # Create a logger for this module -logger = logging.getLogger(__name__) # This logger will be used to log messages from this module -logger.debug("Logging level of backend logger has been configured") +# logger = logging.getLogger(__name__) # This logger will be used to log messages from this module +# logger.debug("Logging level of backend logger has been configured") +global_state = GlobalState() # Import the singleton that holds global states (e.g., logger) +logger = global_state.getLogger(__name__) # Logger for this module, inherit properties of the root logger +# llm = global_state.get_llm() + # Find out the path to current directory according to the Python interpreter (venv) logger.debug("Current working directory: %s", os.getcwd()) @@ -31,6 +36,7 @@ def index(): logger.debug("Entering route '/'") api_endpoint = os.environ['BE_API_ENDPOINT'] # Retrieve the environment variable logger.debug("API endpoint: %s", api_endpoint) + use_model = global_state.get_llm() with open('smartassist/src/html/client.html', 'r') as f: client_html = f.read() logger.debug("Client HTML (first few characters): %s", client_html[:50]) # Print to see if it's loading @@ -114,12 +120,10 @@ def smartassist(): return jsonify({"response": response}) def get_response(user_query): - # Create a client object for interacting with OLLAMA API - client = Client() - # Generate and retrieve the response based on user's query - response = client.generate_response(user_query) - # Return the generated response - return response + client = Client() # Create a client object for interacting with OLLAMA API + response = client.generate_response(user_query) # Generate and retrieve the response based on user's query + return response + def run_flask(fport=5005): """ diff --git a/smartassist/src/html/client.html b/smartassist/src/html/client.html index 6590389..02f3459 100644 --- a/smartassist/src/html/client.html +++ b/smartassist/src/html/client.html @@ -17,16 +17,11 @@ - +