Skip to content

detector: add startswith matching for StringDetector base class#1075

Merged
jmartin-tech merged 3 commits intoNVIDIA:mainfrom
leondz:feature/string_startswith
Jan 17, 2025
Merged

detector: add startswith matching for StringDetector base class#1075
jmartin-tech merged 3 commits intoNVIDIA:mainfrom
leondz:feature/string_startswith

Conversation

@leondz
Copy link
Collaborator

@leondz leondz commented Jan 15, 2025

Adds a new match type for the StringDetector that fires when the output starts with any of the candidate match strings.

e.g. with "test" in the match strings:

    test_cases = [
        ("this is a test", False),
        ("tests always succeed", True),
    ]

Case sensitivity test also added. Thanks @Eric-Hacker for the implicit suggestion & test case in #1054 .

Verification

  • python -m pytest tests/detectors/test_detectors_base.py

@leondz leondz added the detectors work on code that inherits from or manages Detector label Jan 15, 2025
@leondz leondz requested a review from jmartin-tech January 15, 2025 07:56
@leondz leondz requested a review from jmartin-tech January 17, 2025 15:09
@jmartin-tech jmartin-tech merged commit 81bf441 into NVIDIA:main Jan 17, 2025
9 checks passed
@github-actions github-actions bot locked and limited conversation to collaborators Jan 17, 2025
@leondz leondz deleted the feature/string_startswith branch February 19, 2025 05:39
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

detectors work on code that inherits from or manages Detector

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants