-
Notifications
You must be signed in to change notification settings - Fork 491
fix(content_safety): replace try-except with iterable unpacking for policy violations #1207
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
I incorporated @HarryVTripathi 's much simpler fix, and fixed the conflicts with the |
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## develop #1207 +/- ##
===========================================
+ Coverage 68.65% 68.68% +0.03%
===========================================
Files 161 161
Lines 15978 15970 -8
===========================================
Hits 10969 10969
+ Misses 5009 5001 -8
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
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.
Thank you @gcr for this PR! 🎉
This is a clean and elegant tactical fix for the ValueError: too many values to unpack (expected 2)
issue reported in #1179.
Your solution:
- fixes the immediate crash in the getting started example
- eliminates complex exception handling
- makes the code more resilient to parser variations
- maintains backward compatibility
Much appreciated! 👍
note to dev team: Recommended follow up actions:
# these work fine, proper 2-tuples
(True, []) # safe content
(False, ['s3', 's22', 's23']) # unsafe with violations
# but this breaks the old code
(False, 's3', 's22', 's23') # 4 tuple instead of 2 tuple |
Description
hiii NVidia!
this one-line PR fixes an issue with the
rails.stream_async
example in the "Getting Started" docs. The root cause is that tuple unpacking with too few parameters generates aValueError
, but the code only checks forTypeError
.This change is enough to get the docs example working.
To reproduce, install
v0.13.0
of this library, make sure you have a valid API key in the environment, and run their example:Output:
Related Issue(s)
rails.generate
fails withValueError
#1179Checklist