Update application files, fix LLM models, and create new retriever class

This commit is contained in:
Alex
2024-04-09 15:45:24 +01:00
parent 391f686173
commit 1e26943c3e
6 changed files with 112 additions and 15 deletions

View File

@@ -40,23 +40,22 @@ class ClassicRAG(BaseRetriever):
docs = []
else:
docsearch = VectorCreator.create_vectorstore(settings.VECTOR_STORE, self.vectorstore, settings.EMBEDDINGS_KEY)
docs = docsearch.search(self.question, k=self.chunks)
docs_temp = docsearch.search(self.question, k=self.chunks)
docs = [{"title": i.metadata['title'].split('/')[-1] if i.metadata else i.page_content, "text": i.page_content} for i in docs_temp]
if settings.LLM_NAME == "llama.cpp":
docs = [docs[0]]
return docs
def gen(self):
docs = self._get_data()
# join all page_content together with a newline
docs_together = "\n".join([doc.page_content for doc in docs])
docs_together = "\n".join([doc["text"] for doc in docs])
p_chat_combine = self.prompt.replace("{summaries}", docs_together)
messages_combine = [{"role": "system", "content": p_chat_combine}]
for doc in docs:
if doc.metadata:
yield {"source": {"title": doc.metadata['title'].split('/')[-1], "text": doc.page_content}}
else:
yield {"source": {"title": doc.page_content, "text": doc.page_content}}
yield {"source": doc}
if len(self.chat_history) > 1:
tokens_current_history = 0