PandasAI Agent Overview
While thepai.chat() method is meant to be used in a single session and for exploratory data analysis, an agent can be used for multi-turn conversations.
To instantiate an agent, you can use the following code:
pai.chat() method, an agent will keep track of the state of the conversation and will be able to answer multi-turn conversations. For example:
Follow-up Questions
An agent can handle follow-up questions that continue the existing conversation without starting a new chat. This maintains the conversation context. For example:follow_up method works just like chat but doesn’t clear the conversation memory, allowing the agent to understand context from previous messages.
Using the Agent in a Sandbox Environment
The sandbox works offline and provides an additional layer of security for
code execution. It’s particularly useful when working with untrusted data or
when you need to ensure that code execution is isolated from your main system.
Installation
Before using the sandbox, you need to install Docker on your machine and ensure it is running. First, install the sandbox package:Basic Usage
Here’s how to use the sandbox with your PandasAI agent:Customizing the Sandbox
You can customize the sandbox environment by specifying a custom name and Dockerfile:Training the Agent with local Vector stores
Training agents with local vector stores requires a PandasAI Enterprise
license. See Enterprise Features for more details
or contact us for production use.
ChromaDB, Qdrant or Pinecone vector stores. Here’s how to do it:
An enterprise license is required for using the vector stores locally. See Enterprise Features for licensing information.
If you plan to use it in production, contact us.
