Repository navigation
Conversation
Contributor
|
The latest updates on your projects. Learn more about Vercel for GitHub. 1 Skipped Deployment
|
Contributor
Coverage reportClick to see where and how coverage changed
This report was generated by python-coverage-comment-action |
||||||||||||||||||||||||||||||||||||||||||
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Related Issues
Proposed Changes:
Adds
OpenAIModerationHookinhaystack.hooks.moderation, which checks the messages an Agent sends to its LLM, and its final reply, with the OpenAI Moderation API.before_llmandafter_run. Each run checks only the latest messages in one request: the new user input on the first LLM call, the tool results on later calls, and the final reply atafter_run. Earlier history, system messages and system reminders are not sent.categoriesselects which categories count;category_thresholdssets per-category minimum scores that replace OpenAI's own flag.warm_up/warm_up_async.haystack.agent.hook.moderation.*span tags: messages checked, whether anything was flagged, and the flagged categories with their scores. The checked text isn't recorded, since the Agent's own spans already trace it when content tracing is on.How did you test it?
State, inside anAgent(flagged input and tool results never reach the LLM, flagged final reply is replaced), async, and tracing;hatch run test:typespasses.category_thresholds={"violence": 0.0}.Notes for the reviewer
after_runcomes too late to keep a flagged reply from the user; thebefore_llmcheck is unaffected. Moderating streamed output is tracked separately (https://github.com/deepset-ai/haystack-private/issues/629).stopaction, no error fallback, and no custom block text for now. Each can be added later without breaking changes if users ask for it.Checklist
fix:,feat:,build:,chore:,ci:,docs:,style:,refactor:,perf:,test:and added!in case the PR includes breaking changes.