Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ObservationNameError: name 'Observation' is not defined with create_pandas_dataframe_agent #17

Open
BrendanCowley opened this issue Nov 12, 2024 · 0 comments

Comments

@BrendanCowley
Copy link

BrendanCowley commented Nov 12, 2024

Description:

I'm trying to use the create_pandas_dataframe_agent with the langchain-ibm integration. Whenever I make any queries it always comes back with the error mentioned in the title. It usually falls into a loop where it tries the pandas code but is unable to answer the question because of this and just repeats the same task (or a similar version of it) over and over with no results. The thing is, when I manually try the pandas code that it says it is trying, it usually works exactly as intended. Even weirder is sometimes even though the same error is occurring, it will return the correct answer.

I'm using:
python==3.12.7
langchain==0.3.7
langchain-community==0.3.5
langchain-core==0.3.15
langchain-experimental==0.3.3
langchain-ibm==0.3.2
langchain-text-splitters==0.3.2
langsmith==0.1.142
pandas==2.1.4

Example Code (with certain details removed):

from langchain_experimental.agents.agent_toolkits import create_pandas_dataframe_agent
from langchain_ibm import WatsonxLLM

# Create the LLM
llm = WatsonxLLM(
    model_id="",
    url="",
    project_id="",
    params=params,
    watsonx_client=client
)

df_training_agenda = pd.read_excel("fake.xlsx")

user_query = "What are the different teams?"
response = agent.run(user_query)

The output for this will look like:

> Entering new AgentExecutor chain...
Thought: I need to get the unique values from the 'Team' column.
Action: python_repl_ast
Action Input: df['Team'].unique()
ObservationNameError: name 'Observation' is not defined I need to get the unique values from the 'Team' column.
Action: python_repl_ast
Action Input: df['Team'].unique()
ObservationNameError: name 'Observation' is not defined I need to get the unique values from the 'Team' column.
Action: python_repl_ast
Action Input: df['Team'].unique()
ObservationNameError: name 'Observation' is not defined I need to get the unique values from the 'Team' column.
Action: python_repl_ast
Action Input: df['Team'].unique()

And running df['Team'].unique() with the actual df works and provides the correct answer. Does anyone have any ideas of what the issue is?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant