upgraded configuration tool. Now configuration is pecistant over time.

This commit is contained in:
Saifeddine ALOUI 2023-04-12 22:35:51 +02:00
parent 94409cf0df
commit 8f93b856c1

View File

@ -30,6 +30,75 @@ function populate_models(){
populate_models()
modelInput = document.getElementById('model');
seedInput = document.getElementById('seed');
tempInput = document.getElementById('temp');
nPredictInput = document.getElementById('n-predict');
topKInput = document.getElementById('top-k');
topPInput = document.getElementById('top-p');
repeatPenaltyInput = document.getElementById('repeat-penalty');
repeatLastNInput = document.getElementById('repeat-last-n');
temperatureValue = document.getElementById('temperature-value');
n_predictValue = document.getElementById('n-predict-value');
topkValue = document.getElementById('top-k-value');
toppValue = document.getElementById('top-p-value');
repeatPenaltyValue = document.getElementById('repeat-penalty-value');
repeatLastNValue = document.getElementById('repeat-last-n');
tempInput.addEventListener('input',() => {
temperatureValue.textContent =`Temperature(${tempInput.value})`
})
nPredictInput.addEventListener('input',() => {
n_predictValue.textContent =`N Predict(${nPredictInput.value})`
})
topKInput.addEventListener('input',() => {
topkValue.textContent =`Top-K(${topKInput.value})`
})
topPInput.addEventListener('input',() => {
toppValue.textContent =`Top-P(${topPInput.value})`
})
repeatPenaltyInput.addEventListener('input',() => {
repeatPenaltyValue.textContent =`Repeat penalty(${repeatPenaltyInput.value})`
})
repeatLastNInput.addEventListener('input',() => {
repeatLastNValue.textContent =`Repeat last N(${repeatLastNInput.value})`
})
fetch('/get_config')
.then((response) => response.json())
.then((data) => {
console.log(data);
modelInput.value = data["model"]
seedInput.value = data["seed"]
tempInput.value = data["temp"]
nPredictInput.value = data["n_predict"]
topKInput.value = data["top_k"]
topPInput.value = data["top_p"]
repeatPenaltyInput.textContent = data["repeat_penalty"]
repeatLastNInput.textContent = data["repeat_last_n"]
temperatureValue.textContent =`Temperature(${data["temp"]})`
n_predictValue.textContent =`N Predict(${data["n_predict"]})`
topKValue.textContent =`Top-K(${data["top_k"]})`
topPValue.textContent =`Top-P(${data["top_p"]})`
repeatPenaltyValue.textContent =`Repeat penalty(${data["repeat_penalty"]})`
repeatLastNValue.textContent =`Repeat last N(${data["repeat_last_n"]})`
})
.catch((error) => {
console.error('Error:', error);
});
const submitButton = document.getElementById('submit-model-params');
@ -37,15 +106,6 @@ submitButton.addEventListener('click', (event) => {
// Prevent default form submission
event.preventDefault();
modelInput = document.getElementById('model');
seedInput = document.getElementById('seed');
tempInput = document.getElementById('temp');
nPredictInput = document.getElementById('n-predict');
topKInput = document.getElementById('top-k');
topPInput = document.getElementById('top-p');
repeatPenaltyInput = document.getElementById('repeat-penalty');
repeatLastNInput = document.getElementById('repeat-last-n');
// Get form values and put them in an object
const formValues = {
model: modelInput.value,
@ -57,7 +117,7 @@ submitButton.addEventListener('click', (event) => {
repeatPenalty: repeatPenaltyInput.value,
repeatLastN: repeatLastNInput.value
};
console.log(formValues);
// Use fetch to send form values to Flask endpoint
fetch('/update_model_params', {
method: 'POST',