Skip to content
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

Bugfix: Python 3.9 does not support | for types. #28

Merged
merged 3 commits into from
Jan 13, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions .github/workflows/publish_pypy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
name: Publish to Guardrails Hub

on:
workflow_dispatch:
push:
# Publish when new releases are tagged.
tags:
- '*'

jobs:
setup:
runs-on: ubuntu-latest
steps:
- name: Build & Deploy
uses: guardrails-ai/guardrails/.github/actions/validator_pypi_publish@main
with:
guardrails_token: ${{ secrets.GR_GUARDRAILS_TOKEN }}
validator_id: guardrails/toxic_language
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[project]
name = "toxic_language"
version = "0.0.1"
version = "0.0.2"
description = "Validates whether the generated text is toxic."
authors = [
{name = "Guardrails AI", email = "[email protected]"}
Expand Down
4 changes: 2 additions & 2 deletions validator/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ def validate(self, value: str, metadata: Dict[str, Any]) -> ValidationResult:
else:
return self.validate_full_text(value, metadata)

def _inference_local(self, model_input: str | list) -> Any:
def _inference_local(self, model_input: Union[str, list]) -> Any:
"""Local inference method for the toxic language validator."""

if isinstance(model_input, str):
Expand All @@ -173,7 +173,7 @@ def _inference_local(self, model_input: str | list) -> Any:

return predictions

def _inference_remote(self, model_input: str | list) -> Any:
def _inference_remote(self, model_input: Union[str, list]) -> Any:
"""Remote inference method for the toxic language validator."""

if isinstance(model_input, str):
Expand Down
1 change: 0 additions & 1 deletion validator/post-install.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import nltk
import detoxify

# Download NLTK data if not already present
Expand Down
Loading