This commit is contained in:
saloui 2023-12-21 07:54:53 +01:00
commit 6a9595fed1
3 changed files with 75 additions and 13 deletions

View File

@ -1466,11 +1466,12 @@ class LoLLMsAPI(LollmsApplication):
ASCIIColors.cyan(f"Query:{query}") ASCIIColors.cyan(f"Query:{query}")
else: else:
query = current_message.content query = current_message.content
try:
docs, sorted_similarities = self.personality.persona_data_vectorizer.recover_text(query, top_k=self.config.data_vectorization_nb_chunks) docs, sorted_similarities = self.personality.persona_data_vectorizer.recover_text(query, top_k=self.config.data_vectorization_nb_chunks)
for doc, infos in zip(docs, sorted_similarities): for doc, infos in zip(docs, sorted_similarities):
documentation += f"document chunk:\n{doc}" documentation += f"document chunk:\n{doc}"
except:
self.warning("Couldn't add documentation to the context. Please verify the vector database")
if len(self.personality.text_files) > 0 and self.personality.vectorizer: if len(self.personality.text_files) > 0 and self.personality.vectorizer:
if documentation=="": if documentation=="":
@ -1482,19 +1483,23 @@ class LoLLMsAPI(LollmsApplication):
else: else:
query = current_message.content query = current_message.content
docs, sorted_similarities = self.personality.vectorizer.recover_text(query, top_k=self.config.data_vectorization_nb_chunks) try:
for doc, infos in zip(docs, sorted_similarities): docs, sorted_similarities = self.personality.vectorizer.recover_text(query, top_k=self.config.data_vectorization_nb_chunks)
documentation += f"document chunk:\nchunk path: {infos[0]}\nchunk content:{doc}" for doc, infos in zip(docs, sorted_similarities):
documentation += f"document chunk:\nchunk path: {infos[0]}\nchunk content:{doc}"
except:
self.warning("Couldn't add documentation to the context. Please verify the vector database")
# Check if there is discussion history to add to the prompt # Check if there is discussion history to add to the prompt
if self.config.use_discussions_history and self.long_term_memory is not None: if self.config.use_discussions_history and self.long_term_memory is not None:
if history=="": if history=="":
history="!@>previous discussions:\n" history="!@>previous discussions:\n"
docs, sorted_similarities = self.long_term_memory.recover_text(current_message.content, top_k=self.config.data_vectorization_nb_chunks)
for i,(doc, infos) in enumerate(zip(docs, sorted_similarities)):
history += f"!@>previous discussion {i}:\n!@>discussion title:\n{infos[0]}\ndiscussion content:\n{doc}"
# Add information about the user try:
docs, sorted_similarities = self.long_term_memory.recover_text(current_message.content, top_k=self.config.data_vectorization_nb_chunks)
for i,(doc, infos) in enumerate(zip(docs, sorted_similarities)):
history += f"!@>previous discussion {i}:\n!@>discussion title:\n{infos[0]}\ndiscussion content:\n{doc}"
except:
self.warning("Couldn't add long term memory information to the context. Please verify the vector database") # Add information about the user
user_description="" user_description=""
if self.config.use_user_name_in_discussions: if self.config.use_user_name_in_discussions:
user_description="!@>User description:\n"+self.config.user_description user_description="!@>User description:\n"+self.config.user_description

View File

@ -0,0 +1,25 @@
Hi there,
Let me show you how you can use the new web RAG (Retreival Augmented Generation) proposed on lollms to allow your persona to use a path to a website to learn how to do some new stuff.
Here I'll point it to my FaceAnalyzer library that you can find on my github page then ask it to make an application for detecting my facial landmarks in realtime and show them in green.
The AI will use the content of my github readme in order to accomplish my request. You can also add multiple paths if you have a more complex request that requires more than one library.
We will be using the new MistralAI medium model through MistralAI API. To use this binding you need to create a mistralAI account and get a key that you should put in settings.
Let's start by going to the github of the FaceAnalyzer application then copy its path. Now in lollms, press the globe button and paste the path.
Select Mistral AI binding and the Mistral Medium model from the models zoo.
Now let's ask it to make the code.
As you can see, the code seems correct, it does use the FaceAnalyzer library as it should. Let's execute it.
As you can see, the application works. We didn't need to do multiple turn discussions, the model was good enough to accomplish the task just as I asked.
Combining Lollms, its personas, and its Rag with the power of mistral AI allows you to be more productive.
Thanks for watching
See ya

View File

@ -37,3 +37,35 @@ The first time you run the app, you will need to specify a folder where to put y
Now lollms is installed, but there is no binding installed nor a model. To do this, go to settings tab, select binding s zoo and install a binding depending on your preferences. Here I am using a GPU and want local generation, so I will select Hugging face to use full sized models, GPTQ quantized models or AWQ quantized models. The installation may take some while, you can look at the install details in the console window. Now lollms is installed, but there is no binding installed nor a model. To do this, go to settings tab, select binding s zoo and install a binding depending on your preferences. Here I am using a GPU and want local generation, so I will select Hugging face to use full sized models, GPTQ quantized models or AWQ quantized models. The installation may take some while, you can look at the install details in the console window.
Please reboot the app after installing a binding as some of the installed libraries may need a fresh reboot to function properly.
Now that we have rebooted the tool, let's get back to the settings tab to install and select a model.
Go to models zoo and select a model. The models depend on the binding you have selected. Here in hugging face binding, you can use unquantized models, GPTQ quantized models or AWQ quantized models.
To install a model press the menu button and select install. Then select the file tto install and validate.
Now wait for the model to be downloaded.
Once downloaded just select the model and it will be loaded.
Now let's go back to the Discussions view.
We now can start interacting with the AI.
To create a new discussion, press the + button from the side bar.
Now let's type something.
Voilà
As you can see, the AI has written some text. The quality of the generated text depends heavily on the used model and its training. Here we used a small model with 7B parameters.
Bigger models tend to be smarter but some small models like mistral models do yield very good qua
Don't forget to like, share and subscribe.
Thanks for watching
See ya