# Invisible Text

Invisible Text Guardrail detects invisible characters in the output of the language model.

The Guardrail targets invisible Unicode characters, particularly in the Private Use Areas (PUA) of Unicode, which include:

* Basic Multilingual Plane: U+E000 to U+F8FF
* Supplementary Private Use Area-A: U+F0000 to U+FFFFD
* Supplementary Private Use Area-B: U+100000 to U+10FFFD

It detects and removes characters in categories 'Cf' (Format characters), 'Cc' (Control characters), 'Co' (Private use characters), and 'Cn' (Unassigned characters), which are typically non-printable.

**Parameters**:

`data:`

* `prompt` (str): The prompt to scan for invisible characters.

**Interpretation**:

Any invisible characters should not be present in the sanitized\_prompt. Passed if no invisible characters are found, Failed if invisible characters are found and sanitized. Result shows the invisible characters present in the prompt.

**Example:**

Passed Scenario -

```
evaluator.add_test(
    test_names=["invisible_text_guardrail"],
    data={
        "prompt": ["Testing visible text in a prompt."],
    },
).run()

Result = ["Testing visible text in a prompt."]
```

Failed Scenario -

```
evaluator.add_test(
    test_names=["invisible_text_guardrail"],
    data={
        "prompt": ["This is a test string with a ︇︇󠁇z︇ero width space","This is a test string without 󠁀invisible text and a ︇︇󠁇z︇ero."],
    },
).run()

Result = ["This is a test string with a TAG LATIN CAPITAL LETTER G zero width space", "This is a test string without TAG COMMERCIAL AT invisible text and a TAG LATIN CAPITAL LETTER G zero."]
```

#### Code Example:

```python
evaluator.add_test(
    test_names=["invisible_text_guardrail"],
    data={
        "prompt": "This is a test string with a \u200b zero width space",
    },
).run()
evaluator.print_results()
```


---

# 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/invisible-text.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.
