by Democrats and Republicans. \nSOURCES: ../../state_of_the_union.txt"ConversationalRetrievalChain with streaming to stdout‚ÄãOutput from the chain will be streamed to stdout token by token in this example.from langchain.chains.llm import LLMChainfrom langchain.callbacks.streaming_stdout import StreamingStdOutCallbackHandlerfrom langchain.chains.conversational_retrieval.prompts import CONDENSE_QUESTION_PROMPT, QA_PROMPTfrom langchain.chains.question_answering import load_qa_chain# Construct a ConversationalRetrievalChain with a streaming llm for combine docs# and a separate, non-streaming llm for question generationllm = OpenAI(temperature=0)streaming_llm = OpenAI(streaming=True, callbacks=[StreamingStdOutCallbackHandler()], temperature=0)question_generator = LLMChain(llm=llm, prompt=CONDENSE_QUESTION_PROMPT)doc_chain = load_qa_chain(streaming_llm, chain_type="stuff", prompt=QA_PROMPT)qa = ConversationalRetrievalChain(    retriever=vectorstore.as_retriever(), combine_docs_chain=doc_chain, question_generator=question_generator)chat_history = []query = "What did the president say about Ketanji Brown Jackson"result = qa({"question": query, "chat_history": chat_history})     The president said that Ketanji Brown Jackson is one of the nation's top legal minds, a former top litigator in private practice, a former federal public defender, and from a family of public school educators and police officers. He also said that she is a consensus builder and has received a broad range of support from the Fraternal Order of Police to former judges appointed by Democrats and Republicans.chat_history = [(query, result["answer"])]query = "Did he mention who she succeeded"result = qa({"question": query, "chat_history": chat_history})     Ketanji Brown Jackson succeeded Justice Stephen Breyer on the United States Supreme Court.get_chat_history Function‚ÄãYou can also specify a get_chat_history function, which can be used to format the chat_history string.def get_chat_history(inputs)
The ConversationalRetrievalQA chain builds on RetrievalQAChain to provide a chat history component.
The ConversationalRetrievalQA chain builds on RetrievalQAChain to provide a chat history component. ->: by Democrats and Republicans. \nSOURCES: ../../state_of_the_union.txt"ConversationalRetrievalChain with streaming to stdout‚ÄãOutput from the chain will be streamed to stdout token by token in this example.from langchain.chains.llm import LLMChainfrom langchain.callbacks.streaming_stdout import StreamingStdOutCallbackHandlerfrom langchain.chains.conversational_retrieval.prompts import CONDENSE_QUESTION_PROMPT, QA_PROMPTfrom langchain.chains.question_answering import load_qa_chain# Construct a ConversationalRetrievalChain with a streaming llm for combine docs# and a separate, non-streaming llm for question generationllm = OpenAI(temperature=0)streaming_llm = OpenAI(streaming=True, callbacks=[StreamingStdOutCallbackHandler()], temperature=0)question_generator = LLMChain(llm=llm, prompt=CONDENSE_QUESTION_PROMPT)doc_chain = load_qa_chain(streaming_llm, chain_type="stuff", prompt=QA_PROMPT)qa = ConversationalRetrievalChain(    retriever=vectorstore.as_retriever(), combine_docs_chain=doc_chain, question_generator=question_generator)chat_history = []query = "What did the president say about Ketanji Brown Jackson"result = qa({"question": query, "chat_history": chat_history})     The president said that Ketanji Brown Jackson is one of the nation's top legal minds, a former top litigator in private practice, a former federal public defender, and from a family of public school educators and police officers. He also said that she is a consensus builder and has received a broad range of support from the Fraternal Order of Police to former judges appointed by Democrats and Republicans.chat_history = [(query, result["answer"])]query = "Did he mention who she succeeded"result = qa({"question": query, "chat_history": chat_history})     Ketanji Brown Jackson succeeded Justice Stephen Breyer on the United States Supreme Court.get_chat_history Function‚ÄãYou can also specify a get_chat_history function, which can be used to format the chat_history string.def get_chat_history(inputs)