Skip to content

Can I add prompt to create_pandas_dataframe_agent? is that possible? #27917

Answered by dosubot bot
mraguth asked this question in Ask Dosu
Discussion options

You must be logged in to vote

Yes, you can add a prompt template to the create_pandas_dataframe_agent function. In the sample code you provided, you can define a prompt template and integrate it into the agent creation process. Here's an example of how you can do this:

from langchain_openai import ChatOpenAI
from langchain_experimental.agents import create_pandas_dataframe_agent
from langchain.prompts import ChatPromptTemplate, MessagesPlaceholder
import pandas as pd

df = pd.read_csv("titanic.csv")
llm = ChatOpenAI(model="gpt-3.5-turbo", temperature=0)

# Define your prompt template
TEMPLATE = """You are working with a pandas dataframe in Python. The name of the dataframe is `df`.
It is important to understand the a…

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by mraguth
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
1 participant