mirror of
https://github.com/arc53/DocsGPT.git
synced 2025-11-29 00:23:17 +00:00
Update application files, fix LLM models, and create new retriever class
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user