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

sql_agent demo Action and Final Answer appear together to cause an exception #28818

Open
5 tasks done
reatang opened this issue Dec 19, 2024 · 2 comments
Open
5 tasks done
Labels
🤖:bug Related to a bug, vulnerability, unexpected error with an existing feature investigate Flagged for investigation.

Comments

@reatang
Copy link

reatang commented Dec 19, 2024

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

# llm = ChatOpenAI()

db = SQLDatabase.from_uri("sqlite:///../somedb/db.sqlite")

agent_executor = create_sql_agent(
    llm=llm,
    db=db,
    verbose=True,
)
agent_executor.handle_parsing_errors=True

resp = agent_executor.invoke("查询三分球命中率最高的球员")
print(resp)

Error Message and Stack Trace (if applicable)

langsmith:

https://smith.langchain.com/public/e8196299-7b02-4314-a38e-bbae8f2f857e/r

Description

I am using sql_agent at an example time, when the agent is currently running, it is not possible to run the program.

My current LLM analysis calculation time is likely to be a hit. includes_answer = FINAL_ANSWER_ACTION in text Use includes_answer == True ,then the result is FINAL_ANSWER_AND_PARSABLE_ACTION_ERROR_MESSAGE

System Info

look langsmith

@langcarl langcarl bot added the investigate Flagged for investigation. label Dec 19, 2024
@dosubot dosubot bot added the 🤖:bug Related to a bug, vulnerability, unexpected error with an existing feature label Dec 19, 2024
@keenborder786
Copy link
Contributor

Can you try the following:

from langchain_community.utilities import SQLDatabase
from langchain.agents import create_sql_agent
from langchain_openai.chat_models import ChatOpenAI
llm = ChatOpenAI(model="gpt-4")
db = SQLDatabase.from_uri("sqlite:///Chinook.db")
agent_executor = create_sql_agent(
    llm=llm,
    db=db,
    verbose=True,
    agent_executor_kwargs={
        "handle_parsing_errors": True
    }
)
resp = agent_executor.invoke("How many customers are only?")
print(resp)

@reatang
Copy link
Author

reatang commented Dec 20, 2024

yes, i am try.

https://smith.langchain.com/public/971bc360-8f64-4bd3-a020-b512bfe199aa/r

I think it may be the problem with the prompt words, Make Action and Final Answer appear in the same answer.

ReActSingleInputOutputParser@parse

image

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 investigate Flagged for investigation.
Projects
None yet
Development

No branches or pull requests

2 participants