"italian"})    'Harrison ha lavorato a Kensho.'Conversational Retrieval Chain‚ÄãWe can easily add in conversation history. This primarily means adding in chat_message_historyfrom langchain.schema.runnable import RunnableMapfrom langchain.schema import format_documentfrom langchain.prompts.prompt import PromptTemplate_template = """Given the following conversation and a follow up question, rephrase the follow up question to be a standalone question, in its original language.Chat History:{chat_history}Follow Up Input: {question}Standalone question:"""CONDENSE_QUESTION_PROMPT = PromptTemplate.from_template(_template)template = """Answer the question based only on the following context:{context}Question: {question}"""ANSWER_PROMPT = ChatPromptTemplate.from_template(template)DEFAULT_DOCUMENT_PROMPT = PromptTemplate.from_template(template="{page_content}")def _combine_documents(docs, document_prompt = DEFAULT_DOCUMENT_PROMPT, document_separator="\n\n"):    doc_strings = [format_document(doc, document_prompt) for doc in docs]    return document_separator.join(doc_strings)from typing import Tuple, Listdef _format_chat_history(chat_history: List[Tuple]) -> str:    buffer = ""    for dialogue_turn in chat_history:        human = "Human: " + dialogue_turn[0]        ai = "Assistant: " + dialogue_turn[1]        buffer += "\n" + "\n".join([human, ai])    return buffer_inputs = RunnableMap(    standalone_question=RunnablePassthrough.assign(        chat_history=lambda x: _format_chat_history(x['chat_history'])    ) | CONDENSE_QUESTION_PROMPT | ChatOpenAI(temperature=0) | StrOutputParser(),)_context = {    "context": itemgetter("standalone_question") | retriever | _combine_documents,    "question": lambda x: x["standalone_question"]}conversational_qa_chain = _inputs | _context | ANSWER_PROMPT | ChatOpenAI()conversational_qa_chain.invoke({    "question": "where did harrison work?",    "chat_history": [],})    AIMessage(content='Harrison was employed at Kensho.',
Let's look at adding in a retrieval step to a prompt and LLM, which adds up to a "retrieval-augmented generation" chain
Let's look at adding in a retrieval step to a prompt and LLM, which adds up to a "retrieval-augmented generation" chain ->: "italian"})    'Harrison ha lavorato a Kensho.'Conversational Retrieval Chain‚ÄãWe can easily add in conversation history. This primarily means adding in chat_message_historyfrom langchain.schema.runnable import RunnableMapfrom langchain.schema import format_documentfrom langchain.prompts.prompt import PromptTemplate_template = """Given the following conversation and a follow up question, rephrase the follow up question to be a standalone question, in its original language.Chat History:{chat_history}Follow Up Input: {question}Standalone question:"""CONDENSE_QUESTION_PROMPT = PromptTemplate.from_template(_template)template = """Answer the question based only on the following context:{context}Question: {question}"""ANSWER_PROMPT = ChatPromptTemplate.from_template(template)DEFAULT_DOCUMENT_PROMPT = PromptTemplate.from_template(template="{page_content}")def _combine_documents(docs, document_prompt = DEFAULT_DOCUMENT_PROMPT, document_separator="\n\n"):    doc_strings = [format_document(doc, document_prompt) for doc in docs]    return document_separator.join(doc_strings)from typing import Tuple, Listdef _format_chat_history(chat_history: List[Tuple]) -> str:    buffer = ""    for dialogue_turn in chat_history:        human = "Human: " + dialogue_turn[0]        ai = "Assistant: " + dialogue_turn[1]        buffer += "\n" + "\n".join([human, ai])    return buffer_inputs = RunnableMap(    standalone_question=RunnablePassthrough.assign(        chat_history=lambda x: _format_chat_history(x['chat_history'])    ) | CONDENSE_QUESTION_PROMPT | ChatOpenAI(temperature=0) | StrOutputParser(),)_context = {    "context": itemgetter("standalone_question") | retriever | _combine_documents,    "question": lambda x: x["standalone_question"]}conversational_qa_chain = _inputs | _context | ANSWER_PROMPT | ChatOpenAI()conversational_qa_chain.invoke({    "question": "where did harrison work?",    "chat_history": [],})    AIMessage(content='Harrison was employed at Kensho.',