upgraded code

This commit is contained in:
Saifeddine ALOUI 2023-11-22 20:23:22 +01:00
parent 3a3dab0a6c
commit 8b7690d0d7
2 changed files with 20 additions and 5 deletions

View File

@ -23,7 +23,12 @@ class EXTENSION_TYPE(Enum):
class LOLLMSExtension(): class LOLLMSExtension():
def __init__(self, name:str, script_path:str|Path, config:TypedConfig, app) -> None: def __init__(self,
name:str,
script_path:str|Path,
config:TypedConfig,
app,
installation_option:InstallOption=InstallOption.INSTALL_IF_NECESSARY) -> None:
self.name = name self.name = name
self.app = app self.app = app
self.config = config self.config = config
@ -36,6 +41,14 @@ class LOLLMSExtension():
self.configuration_path.mkdir(parents=True, exist_ok=True) self.configuration_path.mkdir(parents=True, exist_ok=True)
self.configuration_path= self.configuration_path/"config.yaml" self.configuration_path= self.configuration_path/"config.yaml"
self.installation_option = installation_option
self.configuration_file_path = self.configuration_path/f"config.yaml"
# Installation
if (not self.configuration_file_path.exists() or self.installation_option==InstallOption.FORCE_INSTALL) and self.installation_option!=InstallOption.NEVER_INSTALL:
self.install()
self.config.save(self.configuration_file_path)
def build_extension(self): def build_extension(self):
return self return self
@ -47,6 +60,7 @@ class LOLLMSExtension():
ASCIIColors.red(f"Installing {self.name}") ASCIIColors.red(f"Installing {self.name}")
ASCIIColors.blue("*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*") ASCIIColors.blue("*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*")
def pre_gen(self, previous_prompt:str, prompt:str): def pre_gen(self, previous_prompt:str, prompt:str):
return previous_prompt, prompt return previous_prompt, prompt
@ -70,11 +84,12 @@ class ExtensionBuilder:
self, self,
extension_path:str, extension_path:str,
lollms_paths:LollmsPaths, lollms_paths:LollmsPaths,
app app,
installation_option:InstallOption=InstallOption.INSTALL_IF_NECESSARY
)->LOLLMSExtension: )->LOLLMSExtension:
extension, script_path = self.getExtension(extension_path, lollms_paths, app) extension, script_path = self.getExtension(extension_path, lollms_paths, app)
return extension(app = app) return extension(app = app, installation_option = installation_option)
def getExtension( def getExtension(
self, self,

View File

@ -1613,7 +1613,7 @@ Yes or No?
["previous_discussion"] ["previous_discussion"]
) )
self.print_prompt("Ask yes or no, this is a generation request",prompt) self.print_prompt("Ask yes or no, this is a generation request",prompt)
is_discussion = self.generate(prompt, max_answer_length).strip().replace("</s>","").replace("<s>","") is_discussion = self.generate(prompt, max_answer_length,temperature=0.01).strip().replace("</s>","").replace("<s>","")
ASCIIColors.cyan(is_discussion) ASCIIColors.cyan(is_discussion)
return "yes" in is_discussion.lower() return "yes" in is_discussion.lower()