You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/v3/agent.mdx
+14-29Lines changed: 14 additions & 29 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -34,38 +34,21 @@ agent.chat('And which one has the most deals?')
34
34
# Output: United States has the most deals
35
35
```
36
36
37
-
### Clarification questions
37
+
### Follow-up Questions
38
38
39
-
An agent will also be able to ask clarification questions if it does not have enough information to answer the query. For example:
39
+
An agent can handle follow-up questions that continue the existing conversation without starting a new chat. This maintains the conversation context. For example:
40
40
41
41
```python
42
-
agent.clarification_questions('What is the GDP of the United States?')
43
-
```
44
-
45
-
This will return up to 3 clarification questions that the agent can ask the user to get more information to answer the query.
46
-
47
-
### Explanation
48
-
49
-
An agent will also be able to explain the answer given to the user. For example:
42
+
# Start a new conversation
43
+
response = agent.chat('What is the total sales?')
44
+
print("First response:", response)
50
45
51
-
```python
52
-
response = agent.chat('What is the GDP of the United States?')
53
-
explanation = agent.explain()
54
-
55
-
print("The answer is", response)
56
-
print("The explanation is", explanation)
46
+
# Continue the conversation without clearing memory
47
+
follow_up_response = agent.follow_up('What about last year?')
48
+
print("Follow-up response:", follow_up_response)
57
49
```
58
50
59
-
### Rephrase Question
60
-
61
-
Rephrase question to get accurate and comprehensive response from the model. For example:
62
-
63
-
```python
64
-
rephrased_query = agent.rephrase_query('What is the GDP of the United States?')
65
-
66
-
print("The rephrased query is", rephrased_query)
67
-
68
-
```
51
+
The `follow_up` method works just like `chat` but doesn't clear the conversation memory, allowing the agent to understand context from previous messages.
69
52
70
53
## Using the Agent in a Sandbox Environment
71
54
@@ -124,10 +107,12 @@ sandbox = DockerSandbox(
124
107
## Training the Agent with local Vector stores
125
108
126
109
<Note>
127
-
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.
110
+
Training agents with local vector stores requires a PandasAI Enterprise
111
+
license. See [Enterprise Features](/v3/enterprise-features) for more details
112
+
or [contact us](https://pandas-ai.com/) for production use.
128
113
</Note>
129
114
130
-
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).
115
+
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).
131
116
132
117
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:
133
118
An enterprise license is required for using the vector stores locally. See [Enterprise Features](/v3/enterprise-features) for licensing information.
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.
7
+
PandasAI v3 maintains backward compatibility for `SmartDataframe`,
8
+
`SmartDatalake`, and `Agent`. However, we recommend migrating to the new
9
+
`pai.DataFrame()` and `pai.chat()` methods for better performance and
10
+
features.
8
11
</Note>
9
12
10
13
## SmartDataframe
@@ -54,6 +57,7 @@ response = df.chat("What are the top countries by sales?")
The `Agent` class works the same way in v3 as it did in v2. The only requirement is to configure the LLM globally.
130
+
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.
126
131
127
132
```python
128
133
from pandasai import Agent
@@ -143,4 +148,24 @@ response = agent.chat("Analyze the data and provide insights")
143
148
144
149
**Key Change:** Configure LLM globally with `pai.config.set()` instead of passing it per-agent.
145
150
146
-
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).
151
+
### New Agent Methods in v3
152
+
153
+
PandasAI v3 introduces new Agent methods that enhance conversational capabilities:
154
+
155
+
-**`follow_up(query)`**: Continue conversations without clearing memory (maintains context)
156
+
157
+
```python
158
+
agent = Agent([df1, df2])
159
+
160
+
# Start conversation
161
+
response = agent.chat('What is the total revenue?')
162
+
163
+
# Follow up without losing context
164
+
follow_up = agent.follow_up('What about last quarter?')
165
+
```
166
+
167
+
**Note:** The `clarification_questions()`, `explain()` and `rephrase_query()` methods have been removed in v3.
168
+
169
+
These methods provide enhanced conversational capabilities not available in v2.
170
+
171
+
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).
Copy file name to clipboardExpand all lines: docs/v3/migration-troubleshooting.mdx
+19-1Lines changed: 19 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -4,7 +4,8 @@ description: "Common issues and solutions when migrating from v2 to v3"
4
4
---
5
5
6
6
<Note>
7
-
This guide covers common issues encountered during migration. For breaking changes and migration steps, see the [Migration Guide](/v3/migration-guide).
7
+
This guide covers common issues encountered during migration. For breaking
8
+
changes and migration steps, see the [Migration Guide](/v3/migration-guide).
8
9
</Note>
9
10
10
11
## Common Issues and Solutions
@@ -55,6 +56,23 @@ pai.config.set(config)
55
56
df = pai.DataFrame(data)
56
57
```
57
58
59
+
### Issue: Agent Methods Not Found
60
+
61
+
**Problem**: `AttributeError: 'Agent' object has no attribute 'clarification_questions'` (or `rephrase_query`, `explain`)
62
+
63
+
**Solution**: These methods have been removed in v3. Use alternatives:
64
+
65
+
```python
66
+
# v2 - These methods are removed
67
+
agent.clarification_questions('What is the GDP?')
68
+
agent.rephrase_query('What is the GDP?')
69
+
agent.explain()
70
+
71
+
# v3 - Use these instead
72
+
response = agent.chat('What is the GDP?')
73
+
follow_up = agent.follow_up('What about last year?') # Maintains context
0 commit comments