How to add prompt template to create_csv_agent?
Labels: name: area: agent, name: auto:question

### Issue with current documentation:

Hey guys! Below is the code which i'm working on

```
import pandas as pd
from IPython.display import Markdown, display
from langchain.agents import create_csv_agent
from langchain.chat_models import ChatOpenAI
from langchain.llms import OpenAI
import os
import pandas as pd

os.environ["OPENAI_API_KEY"] = ""

df = pd.read_csv('https://gist.githubusercontent.com/armgilles/194bcff35001e7eb53a2a8b441e8b2c6/raw/92200bc0a673d5ce2110aaad4544ed6c4010f687/pokemon.csv')

df.to_csv('pokemon.csv', index=False)

# Load the agent
agent = create_csv_agent(OpenAI(temperature=0), "pokemon.csv", verbose=True)

gpt4_agent = create_csv_agent(
    ChatOpenAI(temperature=0, model_name="gpt-4"), "pokemon.csv", verbose=True
)

agent.run("Which pokemon has the highest attack and which has lowest defense?")
```

In the above code, you can see the query has the normal question. How do i add the below prompt template as the question?

```
# Now you can use the json_data in your prompt
prompt_template = f'''If the dataset has the following columns: {json_data}

Understand user questions with different column names and convert them to a JSON format. Here's an example:

Example 1:
User Question: Top 2 zones by Housing Loan in the West and South in the year 2019 excluding small loans and with Discount > 5 and Term Deposit between 10k and 15k 

{{
    "start_date": "01-01-2019",
    "end_date": "31-12-2019",
    "time_stamp_col": "Month",
    "agg_columns": ["Housing Loan"],
    "trend": null,
    "to_start_date": null,
    "to_end_date": null,
    "growth": null,
    "variables_grpby": ["Zone"],
    "filters": {{"Zone": ["West", "South"]}},
    "not_in": {{"Loan Type": ["Small"]}},
    "num_filter": {{
        "gt": [
            ["Discount", 5],
            ["Term Deposit", 10000]
        ],
        "lt": [
            ["Term Deposit", 15000]
        ]
    }},
    "percent": false,
    "top": "2",
    "bottom": null
}}

Example 2:
User Question: What is the Highest Loan Amount and Loan Outstanding by RM Name James in January 2020

{{
    "start_date": "01-01-2020",
    "end_date": "31-01-2020",
    "time_stamp_col": "Due Date",
    "agg_columns": ["Loan Amount", "Loan Outstanding"],
    "trend": null,
    "to_start_date": null,
    "to_end_date": null,
    "growth": null,
    "variables_grpby": [],
    "filters": {{"RM Name": ["James"]}},
    "not_in": {{}},
    "num_filter": {{}},
    "percent": false,
    "top": "1",
    "bottom": null
}}

Example 3:
User Question: Which RM Name with respect to Region has the Highest Interest Outstanding and Principal Outstanding in the year 2019

{{
    "start_date": "01-01-2019",
    "end_date": "31-12-2019",
    "time_stamp_col": "Due Date",
    "agg_columns": ["Interest Outstanding", "Principal Outstanding"],
    "trend": null,
    "to_start_date": null,
    "to_end_date": null,
    "growth": null,
    "variables_grpby": ["RM Name", "Region"],
    "filters": {{}},
    "not_in": {{}},
    "num_filter": {{}},
    "percent": false,
    "top": "1",
    "bottom": null
}}

Example 4:
User Question: Which Branch in North Carolina with respect to Cibil Score Bucket has the Highest Cibil Score in 2019

{{
    "start_date": "01-01-2019",
    "end_date": "31-12-2019",
    "time_stamp_col": "Due Date",
    "agg_columns": ["Cibil Score", "DPD Bucket"],
    "trend": null,
    "to_start_date": null,
    "to_end_date": null,
    "growth": null,
    "variables_grpby": ["Branch"],
    "filters": {{"Region": ["North Carolina"]}},
    "not_in": {{}},
    "num_filter": {{}},
    "percent": false,
    "top": "1",
    "bottom": null
}}

Example 5:
User Question: With respect to Zone, Region, Branch, RM Name what is the Highest Loan Amount, Loan Tenure, Loan Outstanding, EMI Pending, Principal Outstanding

{{
    "start_date": null,
    "end_date": null,
    "time_stamp_col": null,
    "agg_columns": ["Loan Amount", "Loan Tenure", "Loan Outstanding", "EMI Pending", "Principal Outstanding"],
    "trend": null,
    "to_start_date": null,
    "to_end_date": null,
    "growth": null,
    "variables_grpby": ["Zone", "Region", "Branch", "RM Name"],
    "filters": {{}},
    "not_in": {{}},
    "num_filter": {{}},
    "percent": false,
    "top": "1",
    "bottom": null
}}

Example 6:
User Question: Top 2 zones by Housing Loan in the year 2019

{{
    "start_date": "01-01-2019",
    "end_date": "31-12-2019",
    "time_stamp_col": "Due Date",
    "agg_columns": ["Housing Loan"],
    "trend": null,
    "to_start_date": null,
    "to_end_date": null,
    "growth": null,
    "variables_grpby": ["Zone"],
    "filters": {{"Product": ["Home Loan"]}},
    "not_in": {{}},
    "num_filter": {{}},
    "percent": false,
    "top": "2",
    "bottom": null
}}


Our test dataset has the following columns: {json_data}

User Question (to be converted): {{user_question}}'''

user_question = "Which pokemon has the highest attack and which has lowest defense?"
```

Can anyone assist with this?

### Idea or request for content:

_No response_