Changed backends to bindings

This commit is contained in:
Saifeddine ALOUI
2023-05-25 23:24:14 +02:00
parent 4c949bc02e
commit a53faf8ba5
67 changed files with 287 additions and 327 deletions

View File

@ -13,7 +13,7 @@ fetch('/settings')
.then(response => response.text())
.then(html => {
document.getElementById('settings').innerHTML = html;
backendInput = document.getElementById('backend');
bindingInput = document.getElementById('binding');
modelInput = document.getElementById('model');
personalityLanguageInput = document.getElementById('personalities_language');
personalityCategoryInput = document.getElementById('personalities_category');
@ -43,7 +43,7 @@ fetch('/settings')
.then((data) => {
console.log("Received config")
console.log(data);
selectOptionByText(backendInput, data["backend"])
selectOptionByText(bindingInput, data["binding"])
selectOptionByText(modelInput, data["model"])
selectOptionByText(personalityLanguageInput, data["personality_language"])
selectOptionByText(personalityCategoryInput, data["personality_category"])
@ -74,25 +74,25 @@ fetch('/settings')
}
backendInput.addEventListener('input',() => {
console.log(`Backend (${backendInput.value})`)
bindingInput.addEventListener('input',() => {
console.log(`Binding (${bindingInput.value})`)
// Use fetch to send form values to Flask endpoint
fetch('/set_backend', {
fetch('/set_binding', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify({"backend":backendInput.value}),
body: JSON.stringify({"binding":bindingInput.value}),
})
.then((response) => response.json())
.then((data) => {
console.log(data);
if(data["status"]==="no_models_found"){
alert("No models found for this backend. Make sure you select a backend that you have models for or download models from links in our repository")
alert("No models found for this binding. Make sure you select a binding that you have models for or download models from links in our repository")
}
else{
populate_settings();
alert("Backend set successfully")
alert("Binding set successfully")
}
})
.catch((error) => {
@ -115,7 +115,7 @@ fetch('/settings')
.then((data) => {
console.log(data);
populate_settings();
alert("Backend set successfully")
alert("Binding set successfully")
})
.catch((error) => {
console.error('Error:', error);
@ -159,7 +159,7 @@ fetch('/settings')
// Get form values and put them in an object
const formValues = {
seed: seedInput.value,
backend: backendInput.value,
binding: bindingInput.value,
model: modelInput.value,
personality_language:personalityLanguageInput.value,
personality_category:personalityCategoryInput.value,
@ -197,17 +197,17 @@ fetch('/settings')
function populate_settings(){
// Get a reference to the <select> element
const selectBackend = document.getElementById('backend');
const selectBinding = document.getElementById('binding');
const selectModel = document.getElementById('model');
const selectPersonalityLanguage = document.getElementById('personalities_language');
const selectPersonalityCategory = document.getElementById('personalities_category');
const selectPersonality = document.getElementById('personalities');
function populate_backends(){
selectBackend.innerHTML = "";
function populate_bindings(){
selectBinding.innerHTML = "";
// Fetch the list of .bin files from the models subfolder
fetch('/list_backends')
fetch('/list_bindings')
.then(response => response.json())
.then(data => {
if (Array.isArray(data)) {
@ -216,7 +216,7 @@ fetch('/settings')
const optionElement = document.createElement('option');
optionElement.value = filename;
optionElement.textContent = filename;
selectBackend.appendChild(optionElement);
selectBinding.appendChild(optionElement);
});
// fetch('/get_args')
@ -356,7 +356,7 @@ fetch('/settings')
});
populate_backends()
populate_bindings()
populate_models()
populate_personalities_languages()
populate_personalities_categories()