Update agentic-rag.mdx: rewrite_question Node: Role and Content based… #1334
+4
−2
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
… dictionary replaced with LangChain Human Message
As per the docs live officially, in the rewrite_question node, the response of the model for rewriting the query is returned in dictionary format to messages in the state.
return {"messages": [{"role": "user", "content": response.content}]}
I understand this has been done keeping in mind to modify the message's role from ai/assistant to user in the state. While this is not critical for the time being, it might cause errors while printing graph's streaming updates.
for node, update in chunk.items():
print("Update from node", node)
update["messages"][-1].pretty_print()
print("\n\n")
This might have been skipped due to running an example where rewrite node was not required.
However, if the rewrite node comes into play, it would push the dictionary-based format of messages and not the standard Messages class format. The pretty print function is valid only on Message classes and not a dictionary; this would lead to an attribute error: AttributeError: 'dict' object has no attribute 'pretty_print'
For AI learners, especially those who have been exploring LangChain v1.0 docs might get blocked due to this while following the tutorial.
Please merge this one so that it adds to the quality and trust for LangChain docs.
Overview
Type of change
Type: [Replace with: New documentation page / Update existing documentation / Fix typo/bug/link/formatting / Remove outdated content / Other]
Related issues/PRs
Checklist
docs devsrc/docs.jsonif neededAdditional notes