Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 14 additions & 29 deletions docs/v3/agent.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -34,38 +34,21 @@ agent.chat('And which one has the most deals?')
# Output: United States has the most deals
```

### Clarification questions
### Follow-up Questions

An agent will also be able to ask clarification questions if it does not have enough information to answer the query. For example:
An agent can handle follow-up questions that continue the existing conversation without starting a new chat. This maintains the conversation context. For example:

```python
agent.clarification_questions('What is the GDP of the United States?')
```

This will return up to 3 clarification questions that the agent can ask the user to get more information to answer the query.

### Explanation

An agent will also be able to explain the answer given to the user. For example:
# Start a new conversation
response = agent.chat('What is the total sales?')
print("First response:", response)

```python
response = agent.chat('What is the GDP of the United States?')
explanation = agent.explain()

print("The answer is", response)
print("The explanation is", explanation)
# Continue the conversation without clearing memory
follow_up_response = agent.follow_up('What about last year?')
print("Follow-up response:", follow_up_response)
```

### Rephrase Question

Rephrase question to get accurate and comprehensive response from the model. For example:

```python
rephrased_query = agent.rephrase_query('What is the GDP of the United States?')

print("The rephrased query is", rephrased_query)

```
The `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

Expand Down Expand Up @@ -124,10 +107,12 @@ sandbox = DockerSandbox(
## Training the Agent with local Vector stores

<Note>
Training agents with local vector stores requires a PandasAI Enterprise license. See [Enterprise Features](/v3/enterprise-features) for more details or [contact us](https://pandas-ai.com/) for production use.
Training agents with local vector stores requires a PandasAI Enterprise
license. See [Enterprise Features](/v3/enterprise-features) for more details
or [contact us](https://pandas-ai.com/) for production use.
</Note>

It is possible also to use PandasAI with a few-shot learning agent, thanks to the "train with local vector store" enterprise feature (requiring an enterprise license).
It is possible also to use PandasAI with a few-shot learning agent, thanks to the "train with local vector store" enterprise feature (requiring an enterprise license).

If you want to train the agent 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. See [Enterprise Features](/v3/enterprise-features) for licensing information.
Expand Down Expand Up @@ -174,4 +159,4 @@ 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
```
```
31 changes: 28 additions & 3 deletions docs/v3/migration-backwards-compatibility.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,10 @@ description: "Using v2 classes in PandasAI v3"
---

<Note>
PandasAI v3 maintains backward compatibility for `SmartDataframe`, `SmartDatalake`, and `Agent`. However, we recommend migrating to the new `pai.DataFrame()` and `pai.chat()` methods for better performance and features.
PandasAI v3 maintains backward compatibility for `SmartDataframe`,
`SmartDatalake`, and `Agent`. However, we recommend migrating to the new
`pai.DataFrame()` and `pai.chat()` methods for better performance and
features.
</Note>

## SmartDataframe
Expand Down Expand Up @@ -54,6 +57,7 @@ response = df.chat("What are the top countries by sales?")
```

**Benefits of pai.DataFrame():**

- Better integration with semantic layer
- Improved context management
- Enhanced performance
Expand Down Expand Up @@ -114,6 +118,7 @@ response = pai.chat("Who gets paid the most?", employees, salaries)
```

**Benefits of pai.chat():**

- No need to instantiate `SmartDatalake`
- Cleaner, more intuitive API
- Better performance
Expand All @@ -122,7 +127,7 @@ response = pai.chat("Who gets paid the most?", employees, salaries)

## Agent

The `Agent` class works the same way in v3 as it did in v2. The only requirement is to configure the LLM globally.
The `Agent` class works mostly the same way in v3 as it did in v2, but some methods have been removed. The main requirement is to configure the LLM globally.

```python
from pandasai import Agent
Expand All @@ -143,4 +148,24 @@ response = agent.chat("Analyze the data and provide insights")

**Key Change:** Configure LLM globally with `pai.config.set()` instead of passing it per-agent.

For detailed information about Agent usage, see the [Agent documentation](/v3/agent). For information about using Skills with Agent, see the [Skills documentation](/v3/skills).
### New Agent Methods in v3

PandasAI v3 introduces new Agent methods that enhance conversational capabilities:

- **`follow_up(query)`**: Continue conversations without clearing memory (maintains context)

```python
agent = Agent([df1, df2])

# Start conversation
response = agent.chat('What is the total revenue?')

# Follow up without losing context
follow_up = agent.follow_up('What about last quarter?')
```

**Note:** The `clarification_questions()`, `explain()` and `rephrase_query()` methods have been removed in v3.

These methods provide enhanced conversational capabilities not available in v2.

For detailed information about Agent usage, see the [Agent documentation](/v3/agent). For information about using Skills with Agent, see the [Skills documentation](/v3/skills).
35 changes: 35 additions & 0 deletions docs/v3/migration-guide.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,41 @@ agent = Agent([df])

**More details:** See [Skills](/v3/skills) for detailed usage and examples.

### Agent

Agent class works mostly the same, but some methods have been removed in v3.

**Removed methods:** `clarification_questions()`, `rephrase_query()`, `explain()`

**v2:**

```python
from pandasai import Agent

agent = Agent(df)
clarifications = agent.clarification_questions('What is the GDP?')
rephrased = agent.rephrase_query('What is the GDP?')
explanation = agent.explain()
```

**v3:**

```python
from pandasai import Agent

agent = Agent(df)
# ❌ These methods are removed in v3
# Use chat() and follow_up() instead
response = agent.chat('What is the GDP?')
follow_up = agent.follow_up('What about last year?') # New: maintains context
```

**Key Changes:**

- `clarification_questions()`, `rephrase_query()`, and `explain()` have been removed
- New `follow_up()` method maintains conversation context
- Global LLM configuration required

### Training

<Note title="Enterprise Feature">
Expand Down
20 changes: 19 additions & 1 deletion docs/v3/migration-troubleshooting.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ description: "Common issues and solutions when migrating from v2 to v3"
---

<Note>
This guide covers common issues encountered during migration. For breaking changes and migration steps, see the [Migration Guide](/v3/migration-guide).
This guide covers common issues encountered during migration. For breaking
changes and migration steps, see the [Migration Guide](/v3/migration-guide).
</Note>

## Common Issues and Solutions
Expand Down Expand Up @@ -55,6 +56,23 @@ pai.config.set(config)
df = pai.DataFrame(data)
```

### Issue: Agent Methods Not Found

**Problem**: `AttributeError: 'Agent' object has no attribute 'clarification_questions'` (or `rephrase_query`, `explain`)

**Solution**: These methods have been removed in v3. Use alternatives:

```python
# v2 - These methods are removed
agent.clarification_questions('What is the GDP?')
agent.rephrase_query('What is the GDP?')
agent.explain()

# v3 - Use these instead
response = agent.chat('What is the GDP?')
follow_up = agent.follow_up('What about last year?') # Maintains context
```

## Get Support

### Community Support
Expand Down
Loading
Loading