-
Notifications
You must be signed in to change notification settings - Fork 0
Add safety preprocessing and routing to ReactToMe #99
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
Conversation
heliamoh
commented
Nov 10, 2025
- Add a reusable preprocessing graph that rephrases the user query, runs the safety checker, and carries forward structured results.
- Refine the safety checker prompt to return explicit safety and reason_unsafe fields.
- Update BaseGraphBuilder and ReactToMeGraphBuilder to gate RAG vs. refusal based on safety, with a new unsafe-answer generator.
| return BaseState( | ||
| additional_content=AdditionalContent(search_results=search_results) | ||
| **state, | ||
| additional_content=AdditionalContent(search_results=search_results), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does adding **state in spots like this solve some issue with updating the state?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The BaseState(**state, …) merge isn’t there to work around a bug—it’s there because LangGraph hands us an evolving state dict, and we don’t want to drop any of the fields that preprocessing or earlier nodes already wrote (rephrased input, safety tag, chat history, etc.). Postprocess only needs to add additional_content, so merging **state with the new field preserves the existing state while layering on the search results. If we just returned BaseState(additional_content=...), we’d lose everything else that was already in the state and downstream nodes would break.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LangGraph implicitly updates the state using the returned dict without dropping omitted fields, so we shouldn't need to do this.
b7fb7ee to
855ad4d
Compare
|
moving to #100 |