From 5d1dc7e02e89c721c85e62890afbb7c8edeea255 Mon Sep 17 00:00:00 2001 From: ElishaKay Date: Sat, 21 Dec 2024 21:24:32 +0200 Subject: [PATCH] added back report source conditions in researcher.py --- gpt_researcher/skills/researcher.py | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/gpt_researcher/skills/researcher.py b/gpt_researcher/skills/researcher.py index 5235bfd98..89c0de507 100644 --- a/gpt_researcher/skills/researcher.py +++ b/gpt_researcher/skills/researcher.py @@ -94,6 +94,34 @@ async def conduct_research(self): research_data = await self._get_context_by_web_search(self.researcher.query) # ... rest of the conditions ... + elif self.researcher.report_source == ReportSource.Local.value: + document_data = await DocumentLoader(self.researcher.cfg.doc_path).load() + if self.researcher.vector_store: + self.researcher.vector_store.load(document_data) + + research_data = await self._get_context_by_web_search(self.researcher.query, document_data) + + # Hybrid search including both local documents and web sources + elif self.researcher.report_source == ReportSource.Hybrid.value: + document_data = await DocumentLoader(self.researcher.cfg.doc_path).load() + if self.researcher.vector_store: + self.researcher.vector_store.load(document_data) + docs_context = await self._get_context_by_web_search(self.researcher.query, document_data) + web_context = await self._get_context_by_web_search(self.researcher.query) + research_data = f"Context from local documents: {docs_context}\n\nContext from web sources: {web_context}" + + elif self.researcher.report_source == ReportSource.LangChainDocuments.value: + langchain_documents_data = await LangChainDocumentLoader( + self.researcher.documents + ).load() + if self.researcher.vector_store: + self.researcher.vector_store.load(langchain_documents_data) + research_data = await self._get_context_by_web_search( + self.researcher.query, langchain_documents_data + ) + + elif self.researcher.report_source == ReportSource.LangChainVectorStore.value: + research_data = await self._get_context_by_vectorstore(self.researcher.query, self.researcher.vector_store_filter) # Rank and curate the sources self.researcher.context = research_data