nemoguardrails.library.polygraf.request

View as Markdown

Module for handling Polygraf PII detection requests.

Module Contents

Functions

NameDescription
polygraf_requestSend a PII detection request to the Polygraf API.

Data

DEFAULT_TIMEOUT_SECONDS

API

nemoguardrails.library.polygraf.request.polygraf_request(
text: str,
server_endpoint: str,
api_key: typing.Optional[str] = None,
http_client: typing.Optional[nemoguardrails.http.HTTPClient] = None,
timeout: float = DEFAULT_TIMEOUT_SECONDS
) -> typing.List[typing.Dict[str, typing.Any]]
async

Send a PII detection request to the Polygraf API.

Parameters:

text
str

The text to analyze.

server_endpoint
str

The API endpoint URL.

api_key
Optional[str]Defaults to None

The API key for the Polygraf service.

http_client
Optional[HTTPClient]Defaults to None

Optional shared HTTP client. Passing a client lets callers reuse connections across multiple PII checks.

timeout
floatDefaults to DEFAULT_TIMEOUT_SECONDS

Per-request timeout in seconds. Applied to both caller-provided and internally created sessions.

Returns: List[Dict[str, Any]]

The list of entities detected by the Polygraf server.

Raises:

  • ValueError: If the API call fails, times out, or the response cannot be parsed as JSON.
nemoguardrails.library.polygraf.request.DEFAULT_TIMEOUT_SECONDS = 30