upgraded backend

This commit is contained in:
Saifeddine ALOUI 2023-12-27 01:24:47 +01:00
parent 5f1365c306
commit 26c1b62f04
4 changed files with 9 additions and 8 deletions

View File

@ -175,7 +175,7 @@ def models():
"limits": None, "limits": None,
"permission": [] "permission": []
} }
for model in cv.binding.list_models(cv.config) for model in cv.binding.list_models()
] ]
return {'data': data, 'object': 'list'} return {'data': data, 'object': 'list'}

View File

@ -105,8 +105,9 @@ class LoLLMsServer(LollmsApplication):
def list_models(): def list_models():
if self.binding is not None: if self.binding is not None:
models = self.binding.list_models(self.config)
ASCIIColors.yellow("Listing models") ASCIIColors.yellow("Listing models")
models = self.binding.list_models()
ASCIIColors.green("ok")
return jsonify(models) return jsonify(models)
else: else:
return jsonify([]) return jsonify([])
@ -117,7 +118,7 @@ class LoLLMsServer(LollmsApplication):
def get_active_model(): def get_active_model():
if self.binding is not None: if self.binding is not None:
models = self.binding.list_models(self.config) models = self.binding.list_models()
index = models.index(self.config.model_name) index = models.index(self.config.model_name)
ASCIIColors.yellow(f"Recovering active model: {models[index]}") ASCIIColors.yellow(f"Recovering active model: {models[index]}")
return jsonify({"model":models[index],"index":index}) return jsonify({"model":models[index],"index":index})
@ -137,7 +138,7 @@ class LoLLMsServer(LollmsApplication):
""" """
server_infos = {} server_infos = {}
if self.binding is not None: if self.binding is not None:
models = self.binding.list_models(self.config) models = self.binding.list_models()
index = models.index(self.config.model_name) index = models.index(self.config.model_name)
ASCIIColors.yellow(f"Recovering active model: {models[index]}") ASCIIColors.yellow(f"Recovering active model: {models[index]}")
server_infos["binding"]=self.binding.name server_infos["binding"]=self.binding.name
@ -365,7 +366,7 @@ class LoLLMsServer(LollmsApplication):
""" """
if self.binding is None: if self.binding is None:
emit('available_models_list', {'success':False, 'error': "No binding selected"}, room=request.sid) emit('available_models_list', {'success':False, 'error': "No binding selected"}, room=request.sid)
model_list = self.binding.get_available_models() model_list = self.binding.get_available_models(self)
models = [] models = []
for model in model_list: for model in model_list:

View File

@ -467,7 +467,7 @@ class LLMBinding:
pass pass
def list_models(self, config:dict): def list_models(self):
"""Lists the models for this binding """Lists the models for this binding
""" """
models = [] models = []
@ -479,7 +479,7 @@ class LLMBinding:
return models return models
def get_available_models(self): def get_available_models(self, app:LoLLMsCom=None):
# Create the file path relative to the child class's directory # Create the file path relative to the child class's directory
full_data = [] full_data = []
for models_dir_name in self.models_dir_names: for models_dir_name in self.models_dir_names:

View File

@ -267,7 +267,7 @@ class MainMenu(Menu):
models_dir:Path = (self.lollms_app.lollms_paths.personal_models_path/self.lollms_app.config['binding_name']) models_dir:Path = (self.lollms_app.lollms_paths.personal_models_path/self.lollms_app.config['binding_name'])
models_dir.mkdir(parents=True, exist_ok=True) models_dir.mkdir(parents=True, exist_ok=True)
models_list = self.lollms_app.binding.list_models(self.lollms_app.config) + ["Install model", "Change binding", "Back"] models_list = self.lollms_app.binding.list_models() + ["Install model", "Change binding", "Back"]
choice = self.show_menu(models_list) choice = self.show_menu(models_list)
if 1 <= choice <= len(models_list)-3: if 1 <= choice <= len(models_list)-3:
print(f"You selected model: {ASCIIColors.color_green}{models_list[choice - 1]}{ASCIIColors.color_reset}") print(f"You selected model: {ASCIIColors.color_green}{models_list[choice - 1]}{ASCIIColors.color_reset}")