mirror of
https://github.com/ParisNeo/lollms.git
synced 2024-12-24 06:46:40 +00:00
upgraded code
This commit is contained in:
parent
3a3dab0a6c
commit
8b7690d0d7
@ -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,
|
||||||
|
@ -1606,14 +1606,14 @@ Yes or No?
|
|||||||
prompt = pr.build({
|
prompt = pr.build({
|
||||||
"context":context,
|
"context":context,
|
||||||
"question":question
|
"question":question
|
||||||
},
|
},
|
||||||
self.personality.model.tokenize,
|
self.personality.model.tokenize,
|
||||||
self.personality.model.detokenize,
|
self.personality.model.detokenize,
|
||||||
self.personality.model.config.ctx_size,
|
self.personality.model.config.ctx_size,
|
||||||
["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()
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user