langgraph icon indicating copy to clipboard operation
langgraph copied to clipboard

msg should be a list in the rewrite node of langchain_agentic_rag

Open shresthakamal opened this issue 1 year ago • 1 comments

Checked other resources

  • [X] I added a very descriptive title to this issue.
  • [X] I searched the LangChain documentation with the integrated search.
  • [X] I used the GitHub search to find a similar question and didn't find it.
  • [X] I am sure that this is a bug in LangChain rather than my code.

Example Code

def rewrite(state):
    """
    Transform the query to produce a better question.
    
    Args:
        state (messages): The current state
    
    Returns:
        dict: The updated state with re-phrased question
    """
    
    print("---TRANSFORM QUERY---")
    messages = state["messages"]
    question = messages[0].content

    msg = HumanMessage(
        content=f""" \n 
    Look at the input and try to reason about the underlying semantic intent / meaning. \n 
    Here is the initial question:
    \n ------- \n
    {question} 
    \n ------- \n
    Formulate an improved question: """,
    )

Error Message and Stack Trace (if applicable)

ValueError: Invalid input type <class 'langchain_core.messages.human.HumanMessage'>. Must be a PromptValue, str, or list of BaseMessages.

Description

msg should be a list not a HumanMessages

System Info

langchain==0.1.10 langchain-community==0.0.25 langchain-core==0.1.28 langchain-openai==0.0.8 langchain-text-splitters==0.0.1 langchainhub==0.1.14

shresthakamal avatar Mar 02 '24 16:03 shresthakamal

Can be solved using

    msg = [HumanMessage(
        content=f""" \n 
    Look at the input and try to reason about the underlying semantic intent / meaning. \n 
    Here is the initial question:
    \n ------- \n
    {question} 
    \n ------- \n
    Formulate an improved question: """,
    )]

shresthakamal avatar Mar 02 '24 16:03 shresthakamal

fixed! thanks!

hwchase17 avatar Mar 03 '24 23:03 hwchase17