mirror of
https://github.com/QuivrHQ/quivr.git
synced 2024-12-15 09:32:22 +03:00
fix: Refactor conversational_qa_chain initialization in KnowledgeBrainQA (#2629)
# Description Please include a summary of the changes and the related issue. Please also include relevant motivation and context. ## Checklist before requesting a review Please delete options that are not relevant. - [ ] My code follows the style guidelines of this project - [ ] I have performed a self-review of my code - [ ] I have commented hard-to-understand areas - [ ] I have ideally added tests that prove my fix is effective or that my feature works - [ ] New and existing unit tests pass locally with my changes - [ ] Any dependent changes have been merged ## Screenshots (if appropriate):
This commit is contained in:
parent
043bcd17ce
commit
41dec746a7
@ -331,9 +331,10 @@ class KnowledgeBrainQA(BaseModel, QAInterface):
|
||||
async def generate_stream(
|
||||
self, chat_id: UUID, question: ChatQuestion, save_answer: bool = True
|
||||
) -> AsyncIterable:
|
||||
conversational_qa_chain = (
|
||||
self.get_chain() if self.get_chain() else self.knowledge_qa.get_chain()
|
||||
)
|
||||
if hasattr(self, "get_chain") and callable(getattr(self, "get_chain")):
|
||||
conversational_qa_chain = self.get_chain()
|
||||
else:
|
||||
conversational_qa_chain = self.knowledge_qa.get_chain()
|
||||
transformed_history, streamed_chat_history = (
|
||||
self.initialize_streamed_chat_history(chat_id, question)
|
||||
)
|
||||
|
@ -6,8 +6,7 @@ from uuid import UUID
|
||||
|
||||
from langchain.chains import ConversationalRetrievalChain
|
||||
from langchain.llms.base import BaseLLM
|
||||
from langchain.prompts import (HumanMessagePromptTemplate,
|
||||
SystemMessagePromptTemplate)
|
||||
from langchain.prompts import HumanMessagePromptTemplate, SystemMessagePromptTemplate
|
||||
from langchain.retrievers import ContextualCompressionRetriever
|
||||
from langchain.retrievers.document_compressors import FlashrankRerank
|
||||
from langchain.schema import format_document
|
||||
@ -89,7 +88,8 @@ system_message_template = (
|
||||
)
|
||||
|
||||
system_message_template += """
|
||||
When answering use markdown neat.
|
||||
When answering use markdown.
|
||||
Use markdown code blocks for code snippets.
|
||||
Answer in a concise and clear manner.
|
||||
Use the following pieces of context from files provided by the user to answer the users.
|
||||
Answer in the same language as the user question.
|
||||
|
Loading…
Reference in New Issue
Block a user