-
Notifications
You must be signed in to change notification settings - Fork 1.1k
feat: Code scanner Provider impl for moderations api #3100
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
base: main
Are you sure you want to change the base?
feat: Code scanner Provider impl for moderations api #3100
Conversation
62f4e61
to
aee47f0
Compare
from typing import Any | ||
|
||
from codeshield.cs import CodeShield, CodeShieldScanResult |
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.
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.
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.
done
|
||
for text_input in inputs: | ||
log.info(f"Running CodeScannerShield moderation on input: {text_input[:100]}...") | ||
scan_result = await CodeShield.scan_code(text_input) |
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.
some error handling around CodeShield.scan_code(text) would be a good idea, right? Especially when input is not validated.
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.
done
6da7303
to
900424e
Compare
4e720dc
to
dfe4ac0
Compare
@skamenan7 Can you take a look? I have updated |
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=ollama
This PR need to land after this #3098