{})Create your VectorStoreRetrieverMemory‚ÄãThe memory object is instantiated from any vector store retriever.# In actual usage, you would set `k` to be a higher value, but we use k=1 to show that# the vector lookup still returns the semantically relevant informationretriever = vectorstore.as_retriever(search_kwargs=dict(k=1))memory = VectorStoreRetrieverMemory(retriever=retriever)# When added to an agent, the memory object can save pertinent information from conversations or used toolsmemory.save_context({"input": "My favorite food is pizza"}, {"output": "that's good to know"})memory.save_context({"input": "My favorite sport is soccer"}, {"output": "..."})memory.save_context({"input": "I don't the Celtics"}, {"output": "ok"}) ## Notice the first result returned is the memory pertaining to tax help, which the language model deems more semantically relevant# to a 1099 than the other documents, despite them both containing numbers.print(memory.load_memory_variables({"prompt": "what sport should i watch?"})["history"])    input: My favorite sport is soccer    output: ...Using in a chain‚ÄãLet's walk through an example, again setting verbose=True so we can see the prompt.llm = OpenAI(temperature=0) # Can be any valid LLM_DEFAULT_TEMPLATE = """The following is a friendly conversation between a human and an AI. The AI is talkative and provides lots of specific details from its context. If the AI does not know the answer to a question, it truthfully says it does not know.Relevant pieces of previous conversation:{history}(You do not need to use these pieces of information if not relevant)Current conversation:Human: {input}AI:"""PROMPT = PromptTemplate(    input_variables=["history", "input"], template=_DEFAULT_TEMPLATE)conversation_with_summary = ConversationChain(    llm=llm,    prompt=PROMPT,    # We set a very low max_token_limit for the purposes of testing.    memory=memory,    verbose=True)conversation_with_summary.predict(input="Hi, my name is Perry, what's up?")
VectorStoreRetrieverMemory stores memories in a vector store and queries the top-K most "salient" docs every time it is called.
VectorStoreRetrieverMemory stores memories in a vector store and queries the top-K most "salient" docs every time it is called. ->: {})Create your VectorStoreRetrieverMemory‚ÄãThe memory object is instantiated from any vector store retriever.# In actual usage, you would set `k` to be a higher value, but we use k=1 to show that# the vector lookup still returns the semantically relevant informationretriever = vectorstore.as_retriever(search_kwargs=dict(k=1))memory = VectorStoreRetrieverMemory(retriever=retriever)# When added to an agent, the memory object can save pertinent information from conversations or used toolsmemory.save_context({"input": "My favorite food is pizza"}, {"output": "that's good to know"})memory.save_context({"input": "My favorite sport is soccer"}, {"output": "..."})memory.save_context({"input": "I don't the Celtics"}, {"output": "ok"}) ## Notice the first result returned is the memory pertaining to tax help, which the language model deems more semantically relevant# to a 1099 than the other documents, despite them both containing numbers.print(memory.load_memory_variables({"prompt": "what sport should i watch?"})["history"])    input: My favorite sport is soccer    output: ...Using in a chain‚ÄãLet's walk through an example, again setting verbose=True so we can see the prompt.llm = OpenAI(temperature=0) # Can be any valid LLM_DEFAULT_TEMPLATE = """The following is a friendly conversation between a human and an AI. The AI is talkative and provides lots of specific details from its context. If the AI does not know the answer to a question, it truthfully says it does not know.Relevant pieces of previous conversation:{history}(You do not need to use these pieces of information if not relevant)Current conversation:Human: {input}AI:"""PROMPT = PromptTemplate(    input_variables=["history", "input"], template=_DEFAULT_TEMPLATE)conversation_with_summary = ConversationChain(    llm=llm,    prompt=PROMPT,    # We set a very low max_token_limit for the purposes of testing.    memory=memory,    verbose=True)conversation_with_summary.predict(input="Hi, my name is Perry, what's up?")