the sentence to German.', additional_kwargs={}, example=False),      AIMessage(content='Certainly! The translation of "I love programming" from English to German is "Ich liebe das Programmieren."', additional_kwargs={}, example=False)],     'text': 'Certainly! The translation of "I love programming" from English to German is "Ich liebe das Programmieren."'}We can see the chat history preserved in the prompt using the LangSmith trace.Chat Retrieval‚ÄãNow, suppose we want to chat with documents or some other source of knowledge.This is popular use case, combining chat with document retrieval.It allows us to chat with specific information that the model was not trained on.pip install tiktoken chromadbLoad a blog post.from langchain.document_loaders import WebBaseLoaderloader = WebBaseLoader("https://lilianweng.github.io/posts/2023-06-23-agent/")data = loader.load()Split and store this in a vector.from langchain.text_splitter import RecursiveCharacterTextSplittertext_splitter = RecursiveCharacterTextSplitter(chunk_size=500, chunk_overlap=0)all_splits = text_splitter.split_documents(data)from langchain.embeddings import OpenAIEmbeddingsfrom langchain.vectorstores import Chromavectorstore = Chroma.from_documents(documents=all_splits, embedding=OpenAIEmbeddings())Create our memory, as before, but's let's use ConversationSummaryMemory.memory = ConversationSummaryMemory(llm=llm,memory_key="chat_history",return_messages=True)from langchain.chat_models import ChatOpenAIfrom langchain.chains import ConversationalRetrievalChainllm = ChatOpenAI()retriever = vectorstore.as_retriever()qa = ConversationalRetrievalChain.from_llm(llm, retriever=retriever, memory=memory)qa("How do agents use Task decomposition?")    {'question': 'How do agents use Task decomposition?',     'chat_history': [SystemMessage(content='', additional_kwargs={})],     'answer': 'Agents can use task decomposition in several ways:\n\n1. Simple prompting: Agents can use Language Model based prompting to break
Open In Colab
Open In Colab ->: the sentence to German.', additional_kwargs={}, example=False),      AIMessage(content='Certainly! The translation of "I love programming" from English to German is "Ich liebe das Programmieren."', additional_kwargs={}, example=False)],     'text': 'Certainly! The translation of "I love programming" from English to German is "Ich liebe das Programmieren."'}We can see the chat history preserved in the prompt using the LangSmith trace.Chat Retrieval‚ÄãNow, suppose we want to chat with documents or some other source of knowledge.This is popular use case, combining chat with document retrieval.It allows us to chat with specific information that the model was not trained on.pip install tiktoken chromadbLoad a blog post.from langchain.document_loaders import WebBaseLoaderloader = WebBaseLoader("https://lilianweng.github.io/posts/2023-06-23-agent/")data = loader.load()Split and store this in a vector.from langchain.text_splitter import RecursiveCharacterTextSplittertext_splitter = RecursiveCharacterTextSplitter(chunk_size=500, chunk_overlap=0)all_splits = text_splitter.split_documents(data)from langchain.embeddings import OpenAIEmbeddingsfrom langchain.vectorstores import Chromavectorstore = Chroma.from_documents(documents=all_splits, embedding=OpenAIEmbeddings())Create our memory, as before, but's let's use ConversationSummaryMemory.memory = ConversationSummaryMemory(llm=llm,memory_key="chat_history",return_messages=True)from langchain.chat_models import ChatOpenAIfrom langchain.chains import ConversationalRetrievalChainllm = ChatOpenAI()retriever = vectorstore.as_retriever()qa = ConversationalRetrievalChain.from_llm(llm, retriever=retriever, memory=memory)qa("How do agents use Task decomposition?")    {'question': 'How do agents use Task decomposition?',     'chat_history': [SystemMessage(content='', additional_kwargs={})],     'answer': 'Agents can use task decomposition in several ways:\n\n1. Simple prompting: Agents can use Language Model based prompting to break