langchain icon indicating copy to clipboard operation
langchain copied to clipboard

ChatOpenai (gpt3-turbo) isn't compatible with create_pandas_dataframe_agent, create_csv_agent etc

Open Architectshwet opened this issue 1 year ago • 2 comments

I tried creating a pandas dataframe agent (using create_dataframe_agent) with ChatOpenai (gpt3-turbo) as the LLM! But langchain isn't able to parse the LLM's output code. Ofcoure when I use davince model it works

This is the code:

from langchain.llms import OpenAIChat openaichat = OpenAIChat(model_name="gpt-3.5-turbo") agent = create_csv_agent(openaichat, 'fishfry-locations.csv', verbose=True) x = agent.run("How many rows for church?")

This is the output and error

Entering new AgentExecutor chain... Thought: We need to filter the dataframe to only include rows where the venue_type is "Church" and then count the number of rows. Action: python_repl_ast Action Input:

len(df[df['venue_type'] == 'Church'])

Observation: invalid syntax (, line 1) Thought:I need to fix the syntax error by adding a closing parenthesis at the end of the input. Action: python_repl_ast Action Input:

len(df[df['venue_type'] == 'Church']) 

Observation: invalid syntax (, line 1) Thought:

Finished chain.

Architectshwet avatar Apr 16 '23 08:04 Architectshwet

I have seen lots of parsing errors with gpt-3.5-turbo and gpt-4 as well.

engma-linguistics avatar Apr 18 '23 17:04 engma-linguistics

ditto with the pandas agent. often the syntax is actually correct.

tevslin avatar Apr 30 '23 18:04 tevslin

Hi, @Architectshwet! I'm Dosu, and I'm here to help the LangChain team manage their backlog. I wanted to let you know that we are marking this issue as stale.

From what I understand, you reported an issue regarding the compatibility of the ChatOpenai (gpt3-turbo) model with certain agent creation functions like create_pandas_dataframe_agent and create_csv_agent. It seems that the langchain module is unable to parse the output code from the LLM. engma-linguistics and tevslin have also encountered parsing errors with gpt-3.5-turbo and gpt-4, and tevslin mentioned that the syntax is often correct.

Before we proceed, we would like to confirm if this issue is still relevant to the latest version of the LangChain repository. If it is, please let us know by commenting on this issue. Otherwise, feel free to close the issue yourself, or it will be automatically closed in 7 days.

Thank you for your understanding and contribution to the LangChain project. We appreciate your support!

dosubot[bot] avatar Sep 07 '23 16:09 dosubot[bot]