-
Notifications
You must be signed in to change notification settings - Fork 1.1k
chore: enable mypy
type checking for llama_guard safety
provider
#3250
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?
Conversation
mypy
type checking for llama_guard safety
provider
8455e1d
to
27c2eb2
Compare
Signed-off-by: Mustafa Elbehery <[email protected]>
27c2eb2
to
0543f74
Compare
@Elbehery any tooling used to generate these changes? can you declare ? |
hello ✋🏽 i remove the file from then i use |
@@ -271,7 +275,7 @@ def get_safety_categories(self) -> list[str]: | |||
|
|||
return final_categories | |||
|
|||
def validate_messages(self, messages: list[Message]) -> None: | |||
def validate_messages(self, messages: list[Message]) -> list[Message]: |
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.
not sure why this was named validate_messages
in the first place, seems this function is altering the messages and returning messages, can we rename this to process_messages
?
@@ -136,6 +136,8 @@ | |||
|
|||
|
|||
class LlamaGuardSafetyImpl(Safety, ShieldsProtocolPrivate): | |||
shield_store: ShieldStore |
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.
shield_store exists in the parent class of Safety
already, do we need this here as well?
elif isinstance(c, ImageContentItem): | ||
if most_recent_img is None and m.role == Role.user.value: | ||
most_recent_img = c | ||
content.append(c) | ||
# Note: we handle images separately for vision models |
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.
can we remove the comment, this function is only for text input?
| OpenAIToolMessageParam | ||
| OpenAIDeveloperMessageParam | ||
) | ||
openai_messages = [cast(openai_message_param, openai_message)] |
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.
can we move the conversion logic to a different function? Also, move all the imports to top of the module?
What does this PR do?
This PR removes llama_guard from mypy exclude list and fix all type errors to enable strict type checking for the LlamaGuard safety provider implementation.
Changes:
Part of #2647
Supersedes #2676