Compare commits
12 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| a7ce92524a | |||
| b52c98c6b3 | |||
| c8269f3152 | |||
| d553deed13 | |||
| ab23585711 | |||
| 916b6f9e52 | |||
| cfed550a3e | |||
| 5ee7ae520f | |||
| 1f6f0a72d5 | |||
| 9e6e6048f3 | |||
| 538f02e6a7 | |||
| 810b369721 |
@@ -1,22 +1,38 @@
|
|||||||
# Frontend Configuration
|
|
||||||
frontend:
|
|
||||||
url: "http://localhost:5004"
|
|
||||||
|
|
||||||
# Backend Configuration
|
# Backend Configuration
|
||||||
backend:
|
backend:
|
||||||
url: "http://localhost:5004"
|
url: "http://localhost:5004"
|
||||||
api: "/api/chat"
|
api: "/api/chat"
|
||||||
|
|
||||||
|
|
||||||
|
models:
|
||||||
|
- model: "AUTODETECT"
|
||||||
|
title: "Ollama"
|
||||||
|
url: "http://localhost:11434"
|
||||||
|
provider: "ollama"
|
||||||
|
# - model: "AUTODETECT"
|
||||||
|
- model: "AUTODETECT"
|
||||||
|
title: "Ollama-WARA"
|
||||||
|
url: "https://ollama-test.wara-ops.org"
|
||||||
|
requestOptions:
|
||||||
|
headers:
|
||||||
|
Authorization: "${OLLAMA_API_KEY}" # on MacOS: echo "Authorization: Basic $(echo -n 'user:password' | gbase64 -w 0)"
|
||||||
|
provider: "ollama"
|
||||||
|
|
||||||
# Ollama Server Configuration
|
# Ollama Server Configuration
|
||||||
ollama:
|
ollama:
|
||||||
url: "http://localhost:11434"
|
title: "Ollama-local"
|
||||||
|
# url: "http://localhost:11434"
|
||||||
|
url: "https://ollama-test.wara-ops.org"
|
||||||
api_key: "${OLLAMA_API_KEY}" # Refer to environment variable
|
api_key: "${OLLAMA_API_KEY}" # Refer to environment variable
|
||||||
model: "phi3:mini" # Select a model supported by the Ollama server
|
# model: "phi3:mini" # Select a model supported by the Ollama server
|
||||||
# model: "llama3:70b" # Select a model supported by the Ollama server
|
# model: "llama3:70b" # Select a model supported by the Ollama server
|
||||||
|
model: "llama3.1:70b" # Select a model supported by the Ollama server
|
||||||
|
# model: "llama3.1:8b" # Select a model supported by the Ollama server
|
||||||
# model: "llama3:latest" # Select a model supported by the Ollama server
|
# model: "llama3:latest" # Select a model supported by the Ollama server
|
||||||
# model: "mannix/llama3-8b-ablitered-v3:latest" # Select a model supported by the Ollama server
|
# model: "mannix/llama3-8b-ablitered-v3:latest" # Select a model supported by the Ollama server
|
||||||
# model: "mistral-nemo:latest" # Select a model supported by the Ollama server
|
# model: "mistral-nemo:latest" # Select a model supported by the Ollama server
|
||||||
# model: "gemma2:27b"
|
# model: "gemma2:27b"
|
||||||
|
# model: "AUTODETECT"
|
||||||
|
|
||||||
# Logging – comment out the whole section for default level which is INFO
|
# Logging – comment out the whole section for default level which is INFO
|
||||||
logging:
|
logging:
|
||||||
@@ -27,7 +43,7 @@ logging:
|
|||||||
|
|
||||||
# Cache Settings (Optional)
|
# Cache Settings (Optional)
|
||||||
cache:
|
cache:
|
||||||
enabled: true
|
enabled: True
|
||||||
timeout: 60 # Seconds
|
timeout: 60 # Seconds
|
||||||
|
|
||||||
test:
|
test:
|
||||||
|
|||||||
+13
-11
@@ -58,15 +58,15 @@ def set_session():
|
|||||||
resp.set_cookie('session', 'some-value', samesite='None', secure=True) # Add SameSite attribute here
|
resp.set_cookie('session', 'some-value', samesite='None', secure=True) # Add SameSite attribute here
|
||||||
return resp
|
return resp
|
||||||
|
|
||||||
@app.route('/profile')
|
# @app.route('/profile')
|
||||||
def profile():
|
# def profile():
|
||||||
# Retrieve data from the session
|
# # Retrieve data from the session
|
||||||
user_id = session.get('user_id')
|
# user_id = session.get('user_id')
|
||||||
|
|
||||||
if user_id:
|
# if user_id:
|
||||||
return f'User ID: {user_id}'
|
# return f'User ID: {user_id}'
|
||||||
else:
|
# else:
|
||||||
return 'No user ID found'
|
# return 'No user ID found'
|
||||||
|
|
||||||
|
|
||||||
@app.route('/<path:filename>')
|
@app.route('/<path:filename>')
|
||||||
@@ -89,7 +89,8 @@ CORS(app, resources={
|
|||||||
|
|
||||||
|
|
||||||
@app.route('/api/chat', methods=['POST'])
|
@app.route('/api/chat', methods=['POST'])
|
||||||
def chat(url_server = "http://localhost:11434/api/generate", model = "phi3:mini"):
|
def chat(model = "phi3:mini"):
|
||||||
|
# def chat(url_server = "http://localhost:11434/api/generate", model = "phi3:mini"):
|
||||||
"""
|
"""
|
||||||
This function handles the chat. The frontend client (web browser) calls the
|
This function handles the chat. The frontend client (web browser) calls the
|
||||||
backend server through this endpoint (/api/chat) that manage queries
|
backend server through this endpoint (/api/chat) that manage queries
|
||||||
@@ -99,7 +100,7 @@ def chat(url_server = "http://localhost:11434/api/generate", model = "phi3:mini"
|
|||||||
# Get the message from the JSON in the request body
|
# Get the message from the JSON in the request body
|
||||||
data = request.get_json()
|
data = request.get_json()
|
||||||
message = data.get('query')
|
message = data.get('query')
|
||||||
url_server = data.get('url_server', url_server) # Use provided URL or default
|
url_server = data.get('url_server', "https://ollama-test.wara-ops.org/api/generate") # Use provided URL or default
|
||||||
model = data.get('model', model) # Use provided model or default
|
model = data.get('model', model) # Use provided model or default
|
||||||
|
|
||||||
# Get chat history from session storage (e.g., a dictionary)
|
# Get chat history from session storage (e.g., a dictionary)
|
||||||
@@ -122,8 +123,9 @@ def chat(url_server = "http://localhost:11434/api/generate", model = "phi3:mini"
|
|||||||
url = url_server
|
url = url_server
|
||||||
headers = {
|
headers = {
|
||||||
"Content-Type": "application/json",
|
"Content-Type": "application/json",
|
||||||
|
"Authorization": "Basic ZWNzanBlcjoxM2JjMTU4ZDhmNmY5YTU4YTkzZDNmY2I="
|
||||||
}
|
}
|
||||||
|
logger.debug(f"url: {url} headers: {headers}")
|
||||||
response = requests.post(url,
|
response = requests.post(url,
|
||||||
headers=headers,
|
headers=headers,
|
||||||
data=json.dumps(data_to_send))
|
data=json.dumps(data_to_send))
|
||||||
|
|||||||
@@ -6,35 +6,15 @@
|
|||||||
<link rel="stylesheet" href="/css/clientstyle.css">
|
<link rel="stylesheet" href="/css/clientstyle.css">
|
||||||
<!-- <link rel="stylesheet" href="python_test/smartassist/src/css/clientstyle.css"> -->
|
<!-- <link rel="stylesheet" href="python_test/smartassist/src/css/clientstyle.css"> -->
|
||||||
</head>
|
</head>
|
||||||
|
|
||||||
<body>
|
<body>
|
||||||
<h1>Ollama Chat</h1>
|
<h1>Ollama Chat</h1>
|
||||||
<div id="chatbox">
|
<div id="chatbox">
|
||||||
<!-- messages will be rendered here -->
|
<!-- messages will be rendered here -->
|
||||||
</div>
|
</div>
|
||||||
<textarea id="userInput" placeholder="Type your message..." rows="5"></textarea>
|
<textarea id="userInput" placeholder="Type your message..." rows="5"></textarea>
|
||||||
<button id="sendButton" onclick="sendMessage()">Send</button>
|
<button id="sendButton" onclick="window.frontendApi.sendMessage()">Send</button>
|
||||||
|
|
||||||
<!-- Get the apiEndpoint and the useModel -->
|
|
||||||
<!-- <script>
|
|
||||||
const apiEndpoint = window.apiEndpoint;
|
|
||||||
const useModel = window.useModel;
|
|
||||||
console.log("client.html - API Endpoint: ", apiEndpoint);
|
|
||||||
console.log("client.html - use model: ", useModel);
|
|
||||||
</script> -->
|
|
||||||
|
|
||||||
<!-- <script>
|
|
||||||
let apiEndpoint; // Make variable available outside of the scope of the event listener
|
|
||||||
let useModel; // Make variable available outside of the scope of the event listener
|
|
||||||
window.addEventListener('message', function(event) {
|
|
||||||
if (event.origin === 'http://localhost:5004') { // Make sure this matches your origin
|
|
||||||
const { apiEndpoint, useModel } = event.data;
|
|
||||||
console.log("client.html - API Endpoint: ", apiEndpoint);
|
|
||||||
console.log("client.html - use model: ", useModel);
|
|
||||||
window.apiEndpoint = apiEndpoint;
|
|
||||||
window.useModel = useModel;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
</script> -->
|
|
||||||
|
|
||||||
<!-- Marked-it for markdown rendering -->
|
<!-- Marked-it for markdown rendering -->
|
||||||
<script src="https://cdn.jsdelivr.net/npm/markdown-it@14.1.0/dist/markdown-it.min.js"></script>
|
<script src="https://cdn.jsdelivr.net/npm/markdown-it@14.1.0/dist/markdown-it.min.js"></script>
|
||||||
@@ -54,9 +34,6 @@
|
|||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
const chatContainer = document.getElementById('chatbox');
|
const chatContainer = document.getElementById('chatbox');
|
||||||
|
|
||||||
|
|||||||
@@ -30,16 +30,23 @@ def configure():
|
|||||||
env_var_name = value[2:-1] # Extract name between ${}
|
env_var_name = value[2:-1] # Extract name between ${}
|
||||||
return os.getenv(env_var_name, None)
|
return os.getenv(env_var_name, None)
|
||||||
return value
|
return value
|
||||||
|
|
||||||
|
def update_value(value):
|
||||||
|
if isinstance(value, dict): # Dictionaries need recursive check
|
||||||
|
return update_dict_with_env_vars(value)
|
||||||
|
elif isinstance(value, list): # Lists must be traversed element by element
|
||||||
|
return [update_value(item) for item in value]
|
||||||
|
elif isinstance(value, str): # If value is a string it might be an environmnet variable
|
||||||
|
return resolve_env_var(value)
|
||||||
|
else: # Anything else, just keep the old value
|
||||||
|
return value
|
||||||
|
|
||||||
def update_dict_with_env_vars(d):
|
def update_dict_with_env_vars(d): # Check all keys in d
|
||||||
for key in d:
|
for key in d: # Iterate over all keys in the dictionary. The keys seen are all at the top-level of d
|
||||||
if isinstance(d[key], dict):
|
logger.info(f"key investigated now: {key}")
|
||||||
update_dict_with_env_vars(d[key]) # Recursively check nested dictionaries
|
d[key] = update_value(d[key])
|
||||||
elif isinstance(d[key], str):
|
|
||||||
d[key] = resolve_env_var(d[key])
|
|
||||||
return d
|
return d
|
||||||
|
|
||||||
# Update the config dictionary with resolved environment variables
|
|
||||||
updated_config = update_dict_with_env_vars(config)
|
updated_config = update_dict_with_env_vars(config)
|
||||||
|
|
||||||
####################################
|
####################################
|
||||||
@@ -55,20 +62,29 @@ def configure():
|
|||||||
# Extract and export backend API
|
# Extract and export backend API
|
||||||
# endpoint as global state variable
|
# endpoint as global state variable
|
||||||
####################################
|
####################################
|
||||||
if isinstance(updated_config.get('backend'), dict): # Look for 'backend' key
|
# if isinstance(updated_config.get('backend'), dict): # Look for 'backend' key
|
||||||
if isinstance(updated_config['backend'].get('url'), str): # Look for 'url' key
|
# if isinstance(updated_config['backend'].get('url'), str): # Look for 'url' key
|
||||||
url = updated_config['backend'].get('url')
|
# url = updated_config['backend'].get('url')
|
||||||
if isinstance(updated_config['backend'].get('api'), str): # Look for 'api' key
|
# if isinstance(updated_config['backend'].get('api'), str): # Look for 'api' key
|
||||||
api = updated_config['backend'].get('api')
|
# api = updated_config['backend'].get('api')
|
||||||
# backend_api_ep = url+api # Extract API endpoint if defined
|
# # backend_api_ep = url+api # Extract API endpoint if defined
|
||||||
logger.debug(f"Constructing endpoint address as url+api: {url+api}")
|
# 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
|
# 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()}")
|
# logger.debug(f"Backend API endpoint is set to {global_state.get_backend_api_ep()}")
|
||||||
# os.environ['BE_API_ENDPOINT'] = backend_api_ep # Look into alternative way to share this with backend.py
|
|
||||||
|
|
||||||
####################################
|
####################################
|
||||||
# Extract Ollama parameters (url, api_key, model)
|
# 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.get('ollama'), dict): # Look for 'ollama' key
|
||||||
if isinstance(updated_config['ollama'].get('model'), str): # Look for 'model' key
|
if isinstance(updated_config['ollama'].get('model'), str): # Look for 'model' key
|
||||||
model_to_use = updated_config['ollama'].get('model')
|
model_to_use = updated_config['ollama'].get('model')
|
||||||
@@ -115,7 +131,6 @@ def start_backend(config):
|
|||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
conf = configure() # Read config from file and set up config dict
|
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_frontend(config=conf) # Not needed as we are using Flask for backend now
|
||||||
start_backend(config=conf)
|
start_backend(config=conf)
|
||||||
|
|
||||||
|
|||||||
@@ -61,7 +61,7 @@ h1 {
|
|||||||
border-color: #66afe9; /* Blue outline on focus */
|
border-color: #66afe9; /* Blue outline on focus */
|
||||||
}
|
}
|
||||||
|
|
||||||
button[onclick="sendMessage()"] {
|
button[onclick="window.frontendApi.sendMessage()"] {
|
||||||
background-color: #4CAF50; /* Green */
|
background-color: #4CAF50; /* Green */
|
||||||
border: none;
|
border: none;
|
||||||
color: white;
|
color: white;
|
||||||
@@ -75,11 +75,11 @@ button[onclick="sendMessage()"] {
|
|||||||
transition: background-color 0.3s; /* Smooth transition effect */
|
transition: background-color 0.3s; /* Smooth transition effect */
|
||||||
}
|
}
|
||||||
|
|
||||||
button[onclick="sendMessage()"]:hover {
|
button[onclick="window.frontendApi.sendMessage()"]:hover {
|
||||||
background-color: #b2b2b2; /* Light Grey on hover */
|
background-color: #b2b2b2; /* Light Grey on hover */
|
||||||
}
|
}
|
||||||
|
|
||||||
button[onclick="sendMessage()"]:active {
|
button[onclick="window.frontendApi.sendMessage()"]:active {
|
||||||
background-color: #6f6f6f; /* Dark Grey when clicked */
|
background-color: #6f6f6f; /* Dark Grey when clicked */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,111 +1,3 @@
|
|||||||
|
|
||||||
// // Get the user input element from the DOM
|
|
||||||
// const chatbox = document.getElementById('chatbox');
|
|
||||||
// const userInput = document.getElementById('userInput');
|
|
||||||
|
|
||||||
// const parser = window.markdownit({
|
|
||||||
// linkify: true,
|
|
||||||
// strikethrough: true,
|
|
||||||
// });
|
|
||||||
|
|
||||||
// parser.enable(['table']);
|
|
||||||
|
|
||||||
// // const apiEndpoint = window.apiEndpoint; // Get the API endpoint
|
|
||||||
// // const useModel = window.useModel; // Get whether to use a model or not
|
|
||||||
// // console.log("frontend.js - API Endpoint: ", window.apiEndpoint);
|
|
||||||
// // console.log("frontend.js - Use model: ", window.useModel);
|
|
||||||
|
|
||||||
// let apiEndpoint; // Make variable available outside of the scope of the event listener
|
|
||||||
// let useModel; // Make variable available outside of the scope of the event listener
|
|
||||||
// window.addEventListener('message', function(event) {
|
|
||||||
// if (event.origin === 'http://localhost:5004') { // Make sure this matches your origin
|
|
||||||
// const { apiEndpoint, useModel } = event.data;
|
|
||||||
// console.log("client.html - API Endpoint: ", apiEndpoint);
|
|
||||||
// console.log("client.html - use model: ", useModel);
|
|
||||||
// window.apiEndpoint = apiEndpoint;
|
|
||||||
// window.useModel = useModel;
|
|
||||||
// }
|
|
||||||
// });
|
|
||||||
|
|
||||||
// console.log("frontend.js - API Endpoint: ", window.apiEndpoint);
|
|
||||||
// console.log("frontend.js - Use model: ", window.useModel);
|
|
||||||
|
|
||||||
// // Define a function to send the user's message to the AI
|
|
||||||
// function sendMessage() {
|
|
||||||
// // Get the user's input message and trim any whitespace
|
|
||||||
// const query = userInput.value.trim();
|
|
||||||
|
|
||||||
// // Check if the message is not empty
|
|
||||||
// if (query !== '') {
|
|
||||||
|
|
||||||
// // fetch(`${apiEndpoint}`, {
|
|
||||||
// fetch(apiEndpoint, {
|
|
||||||
// method: 'POST',
|
|
||||||
// headers: { 'Content-Type': 'application/json' },
|
|
||||||
// body: JSON.stringify({ query, model: useModel }), // Add these parameters here
|
|
||||||
// // body: JSON.stringify({ query, url_server: "http://your-custom-url", model: "phi3:mini" }), // Add these parameters here
|
|
||||||
// })
|
|
||||||
// .then(response => response.json())
|
|
||||||
// .then(data => {
|
|
||||||
// // Get the AI's response from the API data
|
|
||||||
// const aiResponse = data.response;
|
|
||||||
|
|
||||||
// // Render the user's original message in the chatbox
|
|
||||||
// renderMessage(query, 'user-message');
|
|
||||||
|
|
||||||
// // Render the AI's response in the chatbox
|
|
||||||
// renderMessage(aiResponse, 'ai-response');
|
|
||||||
|
|
||||||
// // Clear the user input field for the next message
|
|
||||||
// userInput.value = '';
|
|
||||||
// })
|
|
||||||
// .catch(error => console.error('Error sending message:', error));
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// // Define a function to render a message in the chatbox with a specific class name
|
|
||||||
// function renderMessage(text, className) {
|
|
||||||
// // Create a new div element to hold the message
|
|
||||||
// const messageElement = document.createElement('div');
|
|
||||||
|
|
||||||
// // Add the specified class name to the element
|
|
||||||
// messageElement.className = className;
|
|
||||||
|
|
||||||
// // // Set the text content of the element to the message text
|
|
||||||
// // messageElement.textContent = text;
|
|
||||||
|
|
||||||
// // Use the markdown-it parser
|
|
||||||
// const html = parser.render(text);
|
|
||||||
// messageElement.innerHTML = html;
|
|
||||||
|
|
||||||
// // Append the message element to the chatbox immediately
|
|
||||||
// // chatbox.appendChild(messageElement);
|
|
||||||
|
|
||||||
// // Typeset math in the message element
|
|
||||||
// MathJax.typesetPromise([messageElement]).then(() => {
|
|
||||||
// // No need to append anything here, it's already appended above
|
|
||||||
// chatbox.appendChild(messageElement);
|
|
||||||
|
|
||||||
// });
|
|
||||||
// }
|
|
||||||
|
|
||||||
// // Make the button toggle colour when user presses Enter on keyboard
|
|
||||||
// const sendButton = document.getElementById('sendButton');
|
|
||||||
|
|
||||||
// document.addEventListener('keydown', function(event) {
|
|
||||||
// if (event.key === 'Enter') {
|
|
||||||
// sendButton.style.backgroundColor = '#6f6f6f'; // Dark Grey when Enter is pressed
|
|
||||||
// }
|
|
||||||
// });
|
|
||||||
|
|
||||||
// document.addEventListener('keyup', function() {
|
|
||||||
// sendButton.style.backgroundColor = ''; // Restore the original style when any key is released
|
|
||||||
// });
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Get the user input element from the DOM
|
// Get the user input element from the DOM
|
||||||
const chatbox = document.getElementById('chatbox');
|
const chatbox = document.getElementById('chatbox');
|
||||||
const userInput = document.getElementById('userInput');
|
const userInput = document.getElementById('userInput');
|
||||||
|
|||||||
@@ -25,7 +25,12 @@ class GlobalState:
|
|||||||
cls._instance.logger.setLevel(getattr(logging, cls._instance.log_level)) # Initialize root logger level
|
cls._instance.logger.setLevel(getattr(logging, cls._instance.log_level)) # Initialize root logger level
|
||||||
cls._instance.logger.info(" __new__(cls): Logger in GlobalState created: %s", cls._instance.logger)
|
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.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
|
# 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
|
return cls._instance
|
||||||
|
|
||||||
def configure_logging(self, level=None):
|
def configure_logging(self, level=None):
|
||||||
@@ -65,11 +70,25 @@ class GlobalState:
|
|||||||
"""Getter for which LLM is used for queries"""
|
"""Getter for which LLM is used for queries"""
|
||||||
return self.llm
|
return self.llm
|
||||||
|
|
||||||
def set_backend_api_ep(self, be_api_ep=None):
|
def set_backend(self, backend=None):
|
||||||
"""Set backend API endpoint"""
|
"""Set backend that web clients connect to"""
|
||||||
self.backend_api_ep = be_api_ep
|
self.backend = backend
|
||||||
|
|
||||||
|
def get_backend(self):
|
||||||
|
"""Getter for backend that web clients connect to"""
|
||||||
|
return self.backend
|
||||||
|
|
||||||
def get_backend_api_ep(self):
|
def get_backend_api_ep(self):
|
||||||
"""Getter for backend API endpoint"""
|
"""Getter for backend API endpoint"""
|
||||||
return self.backend_api_ep
|
return self.backend["url"]+self.backend["api"]
|
||||||
|
|
||||||
|
def set_models(self, models=None):
|
||||||
|
"""Set the list of models."""
|
||||||
|
if models is not None:
|
||||||
|
if not isinstance(models, list):
|
||||||
|
raise ValueError("Models must be a list, even if there is just one model")
|
||||||
|
self.models = models
|
||||||
|
|
||||||
|
def get_models(self):
|
||||||
|
"""Return the list of models"""
|
||||||
|
return self.models
|
||||||
Reference in New Issue
Block a user