diff --git a/.github/workflows/publish_pypy.yml b/.github/workflows/publish_pypy.yml new file mode 100644 index 0000000..3a1ff8d --- /dev/null +++ b/.github/workflows/publish_pypy.yml @@ -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 \ No newline at end of file diff --git a/pyproject.toml b/pyproject.toml index 1919b18..49d40f1 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -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 = "contact@guardrailsai.com"} diff --git a/validator/main.py b/validator/main.py index 20eef1c..bd6f47e 100644 --- a/validator/main.py +++ b/validator/main.py @@ -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): @@ -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): diff --git a/validator/post-install.py b/validator/post-install.py index 0f635de..f690a3a 100644 --- a/validator/post-install.py +++ b/validator/post-install.py @@ -1,4 +1,3 @@ -import nltk import detoxify # Download NLTK data if not already present