KeyError: 'llm' in create_pandas_dataframe_agent
Labels: name: area: agent, name: auto:bug

### System Info

python=3.11
langchain= latest

### Who can help?

_No response_

### Information

- [ ] The official example notebooks/scripts
- [ ] My own modified scripts

### Related Components

- [ ] LLMs/Chat Models
- [ ] Embedding Models
- [ ] Prompts / Prompt Templates / Prompt Selectors
- [ ] Output Parsers
- [ ] Document Loaders
- [ ] Vector Stores / Retrievers
- [ ] Memory
- [ ] Agents / Agent Executors
- [ ] Tools / Toolkits
- [ ] Chains
- [ ] Callbacks/Tracing
- [ ] Async

### Reproduction

while running a code with create_pandas_dataframe_agent it throwing key error

from langchain.agents.agent_types import AgentType
from langchain_experimental.agents.agent_toolkits import create_pandas_dataframe_agent
from langchain_openai import ChatOpenAI

import pandas as pd
from langchain_openai import OpenAI

df = pd.read_csv(r"C:\Users\rndbcpsoft\OneDrive\Desktop\test\chat_data_2024-01-05_13-20-11.csv")

# agent = create_pandas_dataframe_agent(
#     ChatOpenAI(temperature=0, model="gpt-3.5-turbo"),
#     df,
#     verbose=True,
#     agent_type=AgentType.OPENAI_FUNCTIONS,
# )

llm = ChatOpenAI(
        temperature=0, model="gpt-3.5-turbo-0613", openai_api_key=openapi_key , streaming=True
    )

pandas_df_agent = create_pandas_dataframe_agent(
    llm,
    df,
    verbose=True,
    agent_type=AgentType.OPENAI_FUNCTIONS,
    handle_parsing_errors=True,
)

error: 
KeyError                                  Traceback (most recent call last)
Cell In[7], [line 12](vscode-notebook-cell:?execution_count=7&line=12)
      [1](vscode-notebook-cell:?execution_count=7&line=1) # agent = create_pandas_dataframe_agent(
      [2](vscode-notebook-cell:?execution_count=7&line=2) #     ChatOpenAI(temperature=0, model="gpt-3.5-turbo"),
      [3](vscode-notebook-cell:?execution_count=7&line=3) #     df,
      [4](vscode-notebook-cell:?execution_count=7&line=4) #     verbose=True,
      [5](vscode-notebook-cell:?execution_count=7&line=5) #     agent_type=AgentType.OPENAI_FUNCTIONS,
      [6](vscode-notebook-cell:?execution_count=7&line=6) # )
      [8](vscode-notebook-cell:?execution_count=7&line=8) llm = ChatOpenAI(
      [9](vscode-notebook-cell:?execution_count=7&line=9)         temperature=0, model="gpt-3.5-turbo-0613", openai_api_key=openapi_key , streaming=True
     [10](vscode-notebook-cell:?execution_count=7&line=10)     )
---> [12](vscode-notebook-cell:?execution_count=7&line=12) pandas_df_agent = create_pandas_dataframe_agent(
     [13](vscode-notebook-cell:?execution_count=7&line=13)     llm,
     [14](vscode-notebook-cell:?execution_count=7&line=14)     df,
     [15](vscode-notebook-cell:?execution_count=7&line=15)     verbose=True,
     [16](vscode-notebook-cell:?execution_count=7&line=16)     agent_type=AgentType.OPENAI_FUNCTIONS,
     [17](vscode-notebook-cell:?execution_count=7&line=17)     handle_parsing_errors=True,
     [18](vscode-notebook-cell:?execution_count=7&line=18) )

File [c:\Users\rndbcpsoft\OneDrive\Desktop\test\envtest\Lib\site-packages\langchain_experimental\agents\agent_toolkits\pandas\base.py:322](file:///C:/Users/rndbcpsoft/OneDrive/Desktop/test/envtest/Lib/site-packages/langchain_experimental/agents/agent_toolkits/pandas/base.py:322), in create_pandas_dataframe_agent(llm, df, agent_type, callback_manager, prefix, suffix, input_variables, verbose, return_intermediate_steps, max_iterations, max_execution_time, early_stopping_method, agent_executor_kwargs, include_df_in_prompt, number_of_head_rows, extra_tools, **kwargs)
    [313](file:///C:/Users/rndbcpsoft/OneDrive/Desktop/test/envtest/Lib/site-packages/langchain_experimental/agents/agent_toolkits/pandas/base.py:313)     _prompt, base_tools = _get_functions_prompt_and_tools(
    [314](file:///C:/Users/rndbcpsoft/OneDrive/Desktop/test/envtest/Lib/site-packages/langchain_experimental/agents/agent_toolkits/pandas/base.py:314)         df,
    [315](file:///C:/Users/rndbcpsoft/OneDrive/Desktop/test/envtest/Lib/site-packages/langchain_experimental/agents/agent_toolkits/pandas/base.py:315)         prefix=prefix,
   (...)
...
---> [57](file:///C:/Users/rndbcpsoft/OneDrive/Desktop/test/envtest/Lib/site-packages/langchain/agents/openai_functions_agent/base.py:57)     if not isinstance(values["llm"], ChatOpenAI):
     [58](file:///C:/Users/rndbcpsoft/OneDrive/Desktop/test/envtest/Lib/site-packages/langchain/agents/openai_functions_agent/base.py:58)         raise ValueError("Only supported with ChatOpenAI models.")
     [59](file:///C:/Users/rndbcpsoft/OneDrive/Desktop/test/envtest/Lib/site-packages/langchain/agents/openai_functions_agent/base.py:59)     return values

KeyError: 'llm'

### Expected behavior

while running a code with create_pandas_dataframe_agent it throwing key error

from langchain.agents.agent_types import AgentType
from langchain_experimental.agents.agent_toolkits import create_pandas_dataframe_agent
from langchain_openai import ChatOpenAI

import pandas as pd
from langchain_openai import OpenAI

df = pd.read_csv(r"C:\Users\rndbcpsoft\OneDrive\Desktop\test\chat_data_2024-01-05_13-20-11.csv")

# agent = create_pandas_dataframe_agent(
#     ChatOpenAI(temperature=0, model="gpt-3.5-turbo"),
#     df,
#     verbose=True,
#     agent_type=AgentType.OPENAI_FUNCTIONS,
# )

llm = ChatOpenAI(
        temperature=0, model="gpt-3.5-turbo-0613", openai_api_key=openapi_key , streaming=True
    )

pandas_df_agent = create_pandas_dataframe_agent(
    llm,
    df,
    verbose=True,
    agent_type=AgentType.OPENAI_FUNCTIONS,
    handle_parsing_errors=True,
)

error: 
KeyError                                  Traceback (most recent call last)
Cell In[7], [line 12](vscode-notebook-cell:?execution_count=7&line=12)
      [1](vscode-notebook-cell:?execution_count=7&line=1) # agent = create_pandas_dataframe_agent(
      [2](vscode-notebook-cell:?execution_count=7&line=2) #     ChatOpenAI(temperature=0, model="gpt-3.5-turbo"),
      [3](vscode-notebook-cell:?execution_count=7&line=3) #     df,
      [4](vscode-notebook-cell:?execution_count=7&line=4) #     verbose=True,
      [5](vscode-notebook-cell:?execution_count=7&line=5) #     agent_type=AgentType.OPENAI_FUNCTIONS,
      [6](vscode-notebook-cell:?execution_count=7&line=6) # )
      [8](vscode-notebook-cell:?execution_count=7&line=8) llm = ChatOpenAI(
      [9](vscode-notebook-cell:?execution_count=7&line=9)         temperature=0, model="gpt-3.5-turbo-0613", openai_api_key=openapi_key , streaming=True
     [10](vscode-notebook-cell:?execution_count=7&line=10)     )
---> [12](vscode-notebook-cell:?execution_count=7&line=12) pandas_df_agent = create_pandas_dataframe_agent(
     [13](vscode-notebook-cell:?execution_count=7&line=13)     llm,
     [14](vscode-notebook-cell:?execution_count=7&line=14)     df,
     [15](vscode-notebook-cell:?execution_count=7&line=15)     verbose=True,
     [16](vscode-notebook-cell:?execution_count=7&line=16)     agent_type=AgentType.OPENAI_FUNCTIONS,
     [17](vscode-notebook-cell:?execution_count=7&line=17)     handle_parsing_errors=True,
     [18](vscode-notebook-cell:?execution_count=7&line=18) )

File [c:\Users\rndbcpsoft\OneDrive\Desktop\test\envtest\Lib\site-packages\langchain_experimental\agents\agent_toolkits\pandas\base.py:322](file:///C:/Users/rndbcpsoft/OneDrive/Desktop/test/envtest/Lib/site-packages/langchain_experimental/agents/agent_toolkits/pandas/base.py:322), in create_pandas_dataframe_agent(llm, df, agent_type, callback_manager, prefix, suffix, input_variables, verbose, return_intermediate_steps, max_iterations, max_execution_time, early_stopping_method, agent_executor_kwargs, include_df_in_prompt, number_of_head_rows, extra_tools, **kwargs)
    [313](file:///C:/Users/rndbcpsoft/OneDrive/Desktop/test/envtest/Lib/site-packages/langchain_experimental/agents/agent_toolkits/pandas/base.py:313)     _prompt, base_tools = _get_functions_prompt_and_tools(
    [314](file:///C:/Users/rndbcpsoft/OneDrive/Desktop/test/envtest/Lib/site-packages/langchain_experimental/agents/agent_toolkits/pandas/base.py:314)         df,
    [315](file:///C:/Users/rndbcpsoft/OneDrive/Desktop/test/envtest/Lib/site-packages/langchain_experimental/agents/agent_toolkits/pandas/base.py:315)         prefix=prefix,
   (...)
...
---> [57](file:///C:/Users/rndbcpsoft/OneDrive/Desktop/test/envtest/Lib/site-packages/langchain/agents/openai_functions_agent/base.py:57)     if not isinstance(values["llm"], ChatOpenAI):
     [58](file:///C:/Users/rndbcpsoft/OneDrive/Desktop/test/envtest/Lib/site-packages/langchain/agents/openai_functions_agent/base.py:58)         raise ValueError("Only supported with ChatOpenAI models.")
     [59](file:///C:/Users/rndbcpsoft/OneDrive/Desktop/test/envtest/Lib/site-packages/langchain/agents/openai_functions_agent/base.py:59)     return values

KeyError: 'llm'