Skip to content

opendatahub-io/guardrails-regex-detector

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Regex Detector

A lightweight HTTP server designed to parse text using predefined patterns or custom regular expressions.It serves as a detection service, primarily integrated with the FMS Guardrails Orchestrator.

Registered patterns

  • ssn (social security number)
  • credit-card
  • email

Sample request

curl -X POST http://localhost:8080/api/v1/text/contents \
  -H "Content-Type: application/json" \
  -d '{
    "contents": [
      "hello", 
      "this is my email address [email protected]", 
      "check out my social 123-45-6789", 
      "this text should not pop up", 
      "my amex 374245455400126"
    ], 
    "detector_params": {
      "regex": [
        "ssn", 
        "email", 
        "credit-card", 
        "^hello$"
      ]
    }
  }'

Sample response

[
  [
    {
      "detection": "custom",
      "detection_type": "custom",
      "end": 2,
      "score": 1.0,
      "start": 0,
      "text": "hi"
    },
    {
      "detection": "EmailAddress",
      "detection_type": "pii",
      "end": 41,
      "score": 1.0,
      "start": 25,
      "text": "[email protected]"
    },
    {
      "detection": "SocialSecurity",
      "detection_type": "pii",
      "end": 31,
      "score": 1.0,
      "start": 20,
      "text": "123-45-6789"
    },
    {
      "detection": "CreditCard",
      "detection_type": "pii",
      "end": 23,
      "score": 1.0,
      "start": 8,
      "text": "374245455400126"
    }
  ]
]

About

A lightweight HTTP server for regex-based guardrailing.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Rust 81.4%
  • Dockerfile 18.6%