Open SatwantKumar opened 1 year ago
To simplify the output of the ConversationalRetrievalChain in this file, we need to modify the create_chain()
function to streamline the retrieval of relevant documents from the vector database, condensation of the question and chat history into a standalone question, and generation of the response with the final answer. Specifically, we need to remove the verbose=True
argument from the ConversationalRetrievalChain
constructor to suppress the intermediate stages of the question answering process and only return the final answer. We also need to remove the return_source_documents=True
argument to avoid returning the intermediate documents. The modified create_chain()
function should look like this:
def create_chain():
db = FAISS.load_local(
folder_path="vector_stores/",
index_name="langchain-python",
embeddings=OpenAIEmbeddings(),
)
question_generator = LLMChain(
llm=ChatOpenAI(
temperature=0,
streaming=True,
),
prompt=CONDENSE_QUESTION_PROMPT,
)
doc_chain = load_qa_chain(
llm=ChatOpenAI(
temperature=0,
streaming=True,
),
chain_type="stuff",
)
return ConversationalRetrievalChain(
combine_docs_chain=doc_chain,
question_generator=question_generator,
retriever=db.as_retriever(),
# Remove verbose=True to suppress intermediate stages
# Remove return_source_documents=True to avoid returning intermediate documents
)
With these changes, the ConversationalRetrievalChain
will only return the final answer, making it easier to extract the answer when used in combination with the FAST API call.
Current plan usage: NaN%
I use this code ,but it didn't work ,it still answer me with other question
Description: Currently, the ConversationalRetrievalChain provides detailed information about the entire process of question answering, including intermediate stages. This can make it harder to extract the final answer, especially when used in combination with the FAST API call.
Implement a feature to simplify the output of the ConversationalRetrievalChain to deliver only the final answer.
This feature should have the following:
Compatibility with chat_history, context, and question inputs for the ConversationalRetrievalChain.
A process that streamlines the retrieval of relevant documents from the vector database, condensation of the question and chat history into a standalone question, and generation of the response with the final answer.
A mechanism to directly retrieve the final answer from the ConversationalRetrievalChain, bypassing the need to traverse manually through the intermediate stages.
Focus for now on changes to the back-end logic, with particular attention to the integration with the FAST API call and compatibility with the rest of the code.