feat: Code scanner Provider impl for moderations api#3100
Merged
Conversation
62f4e61 to
aee47f0
Compare
ashwinb
reviewed
Aug 13, 2025
| import uuid | ||
| from typing import Any | ||
|
|
||
| from codeshield.cs import CodeShield, CodeShieldScanResult |
Contributor
There was a problem hiding this comment.
you should add a if TYPE_CHECKING: since you need the import only for that. this is a really bad import and pulls in random stuff so that's why we had relegated it to within the method.
skamenan7
requested changes
Aug 13, 2025
|
|
||
| for text_input in inputs: | ||
| log.info(f"Running CodeScannerShield moderation on input: {text_input[:100]}...") | ||
| scan_result = await CodeShield.scan_code(text_input) |
Collaborator
There was a problem hiding this comment.
some error handling around CodeShield.scan_code(text) would be a good idea, right? Especially when input is not validated.
6da7303 to
900424e
Compare
4e720dc to
dfe4ac0
Compare
ashwinb
approved these changes
Aug 15, 2025
Contributor
Author
|
@skamenan7 Can you take a look? I have updated |
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.
What does this PR do?
Add CodeScanner implementations
Test Plan
SAFETY_MODEL=CodeScanner LLAMA_STACK_CONFIG=starter uv run pytest -v tests/integration/safety/test_safety.py --text-model=llama3.2:3b-instruct-fp16 --embedding-model=all-MiniLM-L6-v2 --safety-shield=ollamaThis PR need to land after this #3098