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

Agent react cannot accept gpt4 or gpt 4o as input model #28747

Open
5 tasks done
HelloWorldLTY opened this issue Dec 16, 2024 · 4 comments
Open
5 tasks done

Agent react cannot accept gpt4 or gpt 4o as input model #28747

HelloWorldLTY opened this issue Dec 16, 2024 · 4 comments
Labels
🤖:bug Related to a bug, vulnerability, unexpected error with an existing feature

Comments

@HelloWorldLTY
Copy link

Checked other resources

  • I added a very descriptive title to this issue.
  • I searched the LangChain documentation with the integrated search.
  • I used the GitHub search to find a similar question and didn't find it.
  • I am sure that this is a bug in LangChain rather than my code.
  • The bug is not resolved by updating to the latest stable version of LangChain (or the specific integration package).

Example Code

The mimial reproduce code is:

from langchain import hub
from langchain.agents import AgentExecutor, create_react_agent
from langchain_community.tools.tavily_search import TavilySearchResults
from langchain_openai import OpenAI

tools = []

# Get the prompt to use - you can modify this!
prompt = hub.pull("hwchase17/react")

# Choose the LLM to use
llm = ChatOpenAI(temperature=0, model="gpt-4o")

# Construct the ReAct agent
agent = create_react_agent(llm, tools, prompt)



# Create an agent executor by passing in the agent and tools
agent_executor = AgentExecutor(agent=agent, tools=tools, verbose=True)

agent_executor.invoke({"input": "what is LangChain?"})

Error Message and Stack Trace (if applicable)

ile /home/tl688/.conda/envs/cell2sentence/lib/python3.10/site-packages/langchain/agents/output_parsers/react_single_input.py:75, in ReActSingleInputOutputParser.parse(self, text)
74 if not re.search(r"Action\s*\d*\s*:[\s](.?)", text, re.DOTALL):
---> 75 raise OutputParserException(
76 f"Could not parse LLM output: {text}",
77 observation=MISSING_ACTION_AFTER_THOUGHT_ERROR_MESSAGE,
78 llm_output=text,
79 send_to_llm=True,
80 )
81 elif not re.search(
82 r"[\s]Action\s\d*\sInput\s\d*\s*:[\s](.)", text, re.DOTALL
83 ):

OutputParserException: Could not parse LLM output: LangChain is a framework designed to facilitate the development of applications powered by language models. It provides a suite of tools and components that help developers build applications that can interact with language models in a structured and efficient manner. LangChain is particularly useful for creating applications that require complex language processing tasks, such as chatbots, virtual assistants, and other AI-driven communication tools. It supports integration with various language models and offers features for managing conversations, handling inputs and outputs, and maintaining context across interactions.
For troubleshooting, visit: https://python.langchain.com/docs/troubleshooting/errors/OUTPUT_PARSING_FAILURE

Description

This error only happended in gpt4 and gpt4o model, not in 3.5. Replacing it with OpenAI can work.

System Info

The updated version of langchain.

@dosubot dosubot bot added the 🤖:bug Related to a bug, vulnerability, unexpected error with an existing feature label Dec 16, 2024
@keenborder786
Copy link
Contributor

@HelloWorldLTY, which version of langchain are you using. Can you uprade to the latest version. Since I tested the same code and everything seems to be working.

@keenborder786
Copy link
Contributor

But @HelloWorldLTY if you are facing this error then do the following:

agent_executor = AgentExecutor(agent=agent, tools=tools, verbose=True, handle_parsing_errors=True)

Making handle_parsing_errors=True will make sure that agent executor takes care of any parsing error by feeding the parsing error back to llm.

@HelloWorldLTY
Copy link
Author

Hi, I have tried handle_parsing_errors=True but it will repeat error information for me. I think I have updated my longchain. Here is my info:

kiwisolver==1.4.7
langchain==0.3.7
langchain-anthropic==0.3.0
langchain-community==0.3.5
langchain-core==0.3.24
langchain-experimental==0.3.3
langchain-huggingface==0.1.2
langchain-ollama==0.2.0
langchain-openai==0.2.5
langchain-text-splitters==0.3.2
langgraph==0.2.44
langgraph-checkpoint==2.0.2
langgraph-sdk==0.1.35
langsmith==0.1.139

ccurme added a commit that referenced this issue Dec 17, 2024
@HelloWorldLTY
Copy link
Author

Hi, does it mean I can try reactgpt4 or gpt4o with the referred comments? Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🤖:bug Related to a bug, vulnerability, unexpected error with an existing feature
Projects
None yet
Development

No branches or pull requests

2 participants