added files to all personalities

This commit is contained in:
Saifeddine ALOUI 2023-08-24 01:34:18 +02:00
parent e5c3779710
commit 3003ba80f8
3 changed files with 24 additions and 10 deletions

View File

@ -507,6 +507,7 @@ class LoLLMsAPPI(LollmsApplication):
path:Path = self.lollms_paths.personal_uploads_path / self.personality.personality_folder_name
path.mkdir(parents=True, exist_ok=True)
file_path = path / data["filename"]
File64BitsManager.b642file(data["fileData"],file_path)
if self.personality.processor:
self.personality.processor.add_file(file_path, partial(self.process_chunk, client_id=client_id))
else:
@ -972,20 +973,16 @@ class LoLLMsAPPI(LollmsApplication):
composed_messages = self.model.detokenize(t[-nb_tk:])
ASCIIColors.warning(f"Cropping discussion to fit context [using {nb_tk} tokens/{self.config.ctx_size}]")
discussion_messages = composed_messages
tokens = self.model.tokenize(discussion_messages)
if self.config["debug"]:
ASCIIColors.yellow(discussion_messages)
ASCIIColors.info(f"prompt size:{len(tokens)} tokens")
if len(self.personality.files)>0 and self.personality.vectorizer:
pr = PromptReshaper("!@>Documentation:{{doc}}\n{{conditionning}}{{content}}")
pr = PromptReshaper("!@>Document chunks:\n{{doc}}\n{{conditionning}}\n{{content}}")
emb = self.personality.vectorizer.embed_query(message.content)
doc = self.personality.vectorizer.recover_text(emb, top_k=self.config.data_vectorization_nb_chunks)
# TODO, fix
docs, sorted_similarities = self.personality.vectorizer.recover_text(emb, top_k=self.config.data_vectorization_nb_chunks)
discussion_messages = pr.build({
"doc":doc,
"doc":"\n".join(docs),
"conditionning":self.personality.personality_conditioning,
"content":discussion_messages
}, self.model.tokenize, self.model.detokenize, self.config.ctx_size, place_holders_to_sacrifice=["content"])
@ -996,6 +993,10 @@ class LoLLMsAPPI(LollmsApplication):
"content":discussion_messages
}, self.model.tokenize, self.model.detokenize, self.config.ctx_size, place_holders_to_sacrifice=["content"])
if self.config["debug"]:
tokens = self.model.tokenize(discussion_messages)
ASCIIColors.yellow(discussion_messages)
ASCIIColors.info(f"prompt size:{len(tokens)} tokens")
return discussion_messages, message.content, tokens

4
app.py
View File

@ -1510,7 +1510,7 @@ class LoLLMsWebUI(LoLLMsAPPI):
data = request.get_json()
id = data['id']
print(f"- Selecting active personality {id} ...",end="")
if id<len(self.config["personalities"]) and id<len(self.mounted_personalities):
if id<len(self.mounted_personalities):
self.config["active_personality_id"]=id
self.personality = self.mounted_personalities[self.config["active_personality_id"]]
self.apply_settings()
@ -1522,7 +1522,7 @@ class LoLLMsWebUI(LoLLMsAPPI):
"active_personality_id":self.config["active_personality_id"]
})
else:
ASCIIColors.error(f"nok : personality id out of bounds @ {id} >= {len(self.config['personalities'])}")
ASCIIColors.error(f"nok : personality id out of bounds @ {id} >= {len(self.mounted_personalities)}")
return jsonify({"status": False, "error":"Invalid ID"})

View File

@ -0,0 +1,13 @@
Disclaimer:
As any AI model, the models used on lollms are sometimes prone to errors
and bias. This is not a replacement for lawyers but just a tool that may help
you if you didn't understand some terms in a document or if you have
a big document and need to look for a specific part of it.
The quality of the answers will depend on the model you are using.
larger models tend to be better, but there is no garantee that the answer is correct.
Make sure you contact a legal professional for serious matters.
Thanks for watching
See ya