mirror of
https://github.com/hwchase17/langchain
synced 2024-11-06 03:20:49 +00:00
Harrison/parameter (#7081)
add parameter to use original question or not --------- Co-authored-by: Dev 2049 <dev.dev2049@gmail.com> Co-authored-by: Bagatur <baskaryan@gmail.com>
This commit is contained in:
parent
930e319ca7
commit
695e7027e6
@ -63,6 +63,11 @@ class BaseConversationalRetrievalChain(Chain):
|
||||
a new standalone question to be used later on."""
|
||||
output_key: str = "answer"
|
||||
"""The output key to return the final answer of this chain in."""
|
||||
rephrase_question: bool = True
|
||||
"""Whether or not to pass the new generated question to the combine_docs_chain.
|
||||
If True, will pass the new generated question along.
|
||||
If False, will only use the new generated question for retrieval and pass the
|
||||
original question along to the combine_docs_chain."""
|
||||
return_source_documents: bool = False
|
||||
"""Return the retrieved source documents as part of the final result."""
|
||||
return_generated_question: bool = False
|
||||
@ -131,6 +136,7 @@ class BaseConversationalRetrievalChain(Chain):
|
||||
else:
|
||||
docs = self._get_docs(new_question, inputs) # type: ignore[call-arg]
|
||||
new_inputs = inputs.copy()
|
||||
if self.rephrase_question:
|
||||
new_inputs["question"] = new_question
|
||||
new_inputs["chat_history"] = chat_history_str
|
||||
answer = self.combine_docs_chain.run(
|
||||
@ -178,6 +184,7 @@ class BaseConversationalRetrievalChain(Chain):
|
||||
docs = await self._aget_docs(new_question, inputs) # type: ignore[call-arg]
|
||||
|
||||
new_inputs = inputs.copy()
|
||||
if self.rephrase_question:
|
||||
new_inputs["question"] = new_question
|
||||
new_inputs["chat_history"] = chat_history_str
|
||||
answer = await self.combine_docs_chain.arun(
|
||||
@ -212,8 +219,9 @@ class ConversationalRetrievalChain(BaseConversationalRetrievalChain):
|
||||
2. This new question is passed to the retriever and relevant documents are
|
||||
returned.
|
||||
|
||||
3. The retrieved documents are passed to an LLM along with the new question to
|
||||
generate a final answer.
|
||||
3. The retrieved documents are passed to an LLM along with either the new question
|
||||
(default behavior) or the original question and chat history to generate a final
|
||||
response.
|
||||
|
||||
Example:
|
||||
.. code-block:: python
|
||||
|
Loading…
Reference in New Issue
Block a user