Lagt till vidarebefordran av LLM från backen.py till frontend (index.html, client.html, frontend.js
This commit is contained in:
@@ -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):
|
||||
"""
|
||||
|
||||
Reference in New Issue
Block a user