# Ban Substrings

Ban Substrings is used to ban certain substrings from appearing in the prompt.

**Parameters**:

`data:`

* `prompt` (str): Prompt to check for banned substrings.

`arguments:`

* `substrings` (Sequence\[str]): List of substrings to ban.
* `match_type` (str): Type of match to perform. Can be either 'str' or 'word'. Default is 'str'.
* `case_sensitive` (bool, optional): Flag to indicate if the match should be case-sensitive. Default is False.
* `redact` (bool, optional): Flag to indicate if the banned substrings should be redacted. Default is False.
* `contains_all` (bool): Flag to indicate if need to match all substrings instead of any of them. Default is False, contains any.

**Interpretation**:

Values from the substrings list present in the prompt should not be included in the output. Passed if no substrings are present, Failed if substrings are present.

**Example:**

Passed Scenario -

```python
evaluator.add_test(
    test_names=["ban_substrings_guardrail"],
    data={
        "prompt": """Given the personal profile of Johnathan Edward Doe, please summarise the following resume:

Profile:

- Full Name: Johnathan Edward Doe.
- Date of Birth: April 12, 1990.
- Address: 123 Elm Street, Springfield, IL, 62701.
- Email: john.doe@example.com.
- Phone Number: (123) 456-7890.
- Educational Background:
    - Springfield High School, Graduated in 2008;
    - Springfield University, B.Sc. Computer Science, Graduated in 2012.
- Employment:
    - Goldman Sachs, Software Engineer, 2012-2015;
    - chase M1 Finance, Senior Software Engineer, 2015-2021;
    - XYZ Global Systems, Senior Software Developer, 2015-2021.
""",
    },
    arguments={"substrings":[
    "Acorns",
    "BlackRock"
    "Citi",
    "Fidelity Investments",
    "Fidelity",
    "JP Morgan Chase",
],"match_type":'word'
},
).run()

##Result = No banned substrings found in the prompt.
```

Failed Scenario -

```python
evaluator.add_test(
    test_names=["ban_substrings_guardrail"],
    data={
        "prompt": """Given the personal profile of Johnathan Edward Doe, please summarise the following resume:

Profile:

- Full Name: Johnathan Edward Doe.
- Date of Birth: April 12, 1990.
- Address: 123 Elm Street, Springfield, IL, 62701.
- Email: john.doe@fidelity.com.
- Phone Number: (123) 456-7890.
- Educational Background:
    - Springfield High School, Graduated in 2008;
    - Springfield University, B.Sc. Computer Science, Graduated in 2012.
- Employment:
    - JP Morgan Chase, Software Engineer, 2012-2015;
    - chase M1 Finance, Senior Software Engineer, 2015-2021;
    - XYZ Global Systems, Senior Software Developer, 2015-2021.
""",
    },
    arguments={"substrings":[
    "Acorns",
    "XYZ Global Systems",
    "Citi",
    "Fidelity Investments",
    "Fidelity"
],"match_type":'word'
},
).run().print_results()

#Result = Banned substrings found in the prompt.

```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.raga.ai/ragaai-catalyst/ragaai-metric-library/additional-metrics/guardrails/ban-substrings.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
