If you want to train the model with a local vector store, you can use the local ChromaDB, Qdrant or Pinecone vector stores. Here’s how to do it:
An enterprise license is required for using the vector stores locally, (check it out).
If you plan to use it in production, contact us.
Copy
from pandasai import Agentfrom pandasai.ee.vectorstores import ChromaDBfrom pandasai.ee.vectorstores import Qdrantfrom pandasai.ee.vectorstores import Pineconefrom pandasai.ee.vector_stores import LanceDB# Instantiate the vector storevector_store = ChromaDB()# or with Qdrant# vector_store = Qdrant()# or with LanceDBvector_store = LanceDB()# or with Pinecone# vector_store = Pinecone(# api_key="*****",# embedding_function=embedding_function,# dimensions=384, # dimension of your embedding model# )# Instantiate the agent with the custom vector storeagent = Agent("data.csv", vectorstore=vector_store)# Train the modelquery = "What is the total sales for the current fiscal year?"response = """import pandas as pddf = dfs[0]# Calculate the total sales for the current fiscal yeartotal_sales = df[df['date'] >= pd.to_datetime('today').replace(month=4, day=1)]['sales'].sum()result = { "type": "number", "value": total_sales }"""agent.train(queries=[query], codes=[response])response = agent.chat("What is the total sales for the last fiscal year?")print(response)# The model will use the information provided in the training to generate a response