fixed smart router

This commit is contained in:
Saifeddine ALOUI 2024-11-20 01:12:12 +01:00
parent 57c2d7c48f
commit 74f7e37b90

View File

@ -1148,10 +1148,10 @@ class LOLLMSWebUI(LOLLMSElfServer):
self.set_active_model(self.routing_model)
models = [f"{k}" for k,v in self.config.smart_routing_models_description.items()]
output_id, explanation = self.personality.multichoice_question("Select most suitable model to answer the user request given the context:\n", [f"{k}: {v}" for k,v in self.config.smart_routing_models_description.items()], "user request:" + prompt, return_explanation=True)
output_id, explanation = self.personality.multichoice_question("Select most suitable model to answer the user request given the context. Answer with the selected model index followed by an explanation in a new line.", [f"{k}: {v}" for k,v in self.config.smart_routing_models_description.items()], "user request:" + prompt, return_explanation=True)
if output_id >=0 and output_id<len(models):
binding, model_name = self.model_path_to_binding_model(models[output_id])
self.select_model(binding, model_name)
self.select_model(binding, model_name, destroy_previous_model=False)
self.personality.step_end("Routing request")
self.personality.step(f"Choice explanation: {explanation}")
self.personality.step(f"Selected {models[output_id]}")
@ -1159,7 +1159,7 @@ class LOLLMSWebUI(LOLLMSElfServer):
ASCIIColors.error("Model failed to find the most suited model for your request")
self.info("Model failed to find the most suited model for your request")
binding, model_name = self.model_path_to_binding_model(models[0])
self.select_model(binding, model_name)
self.select_model(binding, model_name, destroy_previous_model=False)
self.personality.step_end("Routing request")
self.personality.step(f"Complexity level: {output_id}")
self.personality.step(f"Selected {models[output_id]}")