platform based on PostgreSQL",    "Xata offers a built-in vector type that can be used to store and query vectors",    "Xata includes similarity search"]vector_store = XataVectorStore.from_texts(texts, embeddings, api_key=api_key, db_url=db_url, table_name="docs")After running the above command, if you go to the Xata UI, you should see the documents loaded together with their embeddings in the docs table.Let's now create a ConversationBufferMemory to store the chat messages from both the user and the AI.from langchain.memory import ConversationBufferMemoryfrom uuid import uuid4chat_memory = XataChatMessageHistory(    session_id=str(uuid4()),   # needs to be unique per user session    api_key=api_key,    db_url=db_url,    table_name="memory")memory = ConversationBufferMemory(memory_key="chat_history", chat_memory=chat_memory, return_messages=True)Now it's time to create an Agent to use both the vector store and the chat memory together.from langchain.agents import initialize_agent, AgentTypefrom langchain.agents.agent_toolkits import create_retriever_toolfrom langchain.chat_models import ChatOpenAItool = create_retriever_tool(    vector_store.as_retriever(),     "search_docs",    "Searches and returns documents from the Xata manual. Useful when you need to answer questions about Xata.")tools = [tool]llm = ChatOpenAI(temperature=0)agent = initialize_agent(    tools,    llm,    agent=AgentType.CHAT_CONVERSATIONAL_REACT_DESCRIPTION,    verbose=True,    memory=memory)To test, let's tell the agent our name:agent.run(input="My name is bob")Now, let's now ask the agent some questions about Xata:agent.run(input="What is xata?")Notice that it answers based on the data stored in the document store. And now, let's ask a follow up question:agent.run(input="Does it support similarity search?")And now let's test its memory:agent.run(input="Did I tell you my name? What is it?")PreviousUpstash Redis Chat Message HistoryNextZepSetupCreate a databaseCreate a simple memory
Xata is a serverless data platform, based on PostgreSQL and Elasticsearch. It provides a Python SDK for interacting with your database, and a UI for managing your data. With the XataChatMessageHistory class, you can use Xata databases for longer-term persistence of chat sessions.
Xata is a serverless data platform, based on PostgreSQL and Elasticsearch. It provides a Python SDK for interacting with your database, and a UI for managing your data. With the XataChatMessageHistory class, you can use Xata databases for longer-term persistence of chat sessions. ->: platform based on PostgreSQL",    "Xata offers a built-in vector type that can be used to store and query vectors",    "Xata includes similarity search"]vector_store = XataVectorStore.from_texts(texts, embeddings, api_key=api_key, db_url=db_url, table_name="docs")After running the above command, if you go to the Xata UI, you should see the documents loaded together with their embeddings in the docs table.Let's now create a ConversationBufferMemory to store the chat messages from both the user and the AI.from langchain.memory import ConversationBufferMemoryfrom uuid import uuid4chat_memory = XataChatMessageHistory(    session_id=str(uuid4()),   # needs to be unique per user session    api_key=api_key,    db_url=db_url,    table_name="memory")memory = ConversationBufferMemory(memory_key="chat_history", chat_memory=chat_memory, return_messages=True)Now it's time to create an Agent to use both the vector store and the chat memory together.from langchain.agents import initialize_agent, AgentTypefrom langchain.agents.agent_toolkits import create_retriever_toolfrom langchain.chat_models import ChatOpenAItool = create_retriever_tool(    vector_store.as_retriever(),     "search_docs",    "Searches and returns documents from the Xata manual. Useful when you need to answer questions about Xata.")tools = [tool]llm = ChatOpenAI(temperature=0)agent = initialize_agent(    tools,    llm,    agent=AgentType.CHAT_CONVERSATIONAL_REACT_DESCRIPTION,    verbose=True,    memory=memory)To test, let's tell the agent our name:agent.run(input="My name is bob")Now, let's now ask the agent some questions about Xata:agent.run(input="What is xata?")Notice that it answers based on the data stored in the document store. And now, let's ask a follow up question:agent.run(input="Does it support similarity search?")And now let's test its memory:agent.run(input="Did I tell you my name? What is it?")PreviousUpstash Redis Chat Message HistoryNextZepSetupCreate a databaseCreate a simple memory