nemoguardrails.library.gliner.request
Module for handling GLiNER detection requests.
Module Contents
Functions
Data
API
async
Send a PII detection request to the GLiNER API.
Supports two server formats:
- Custom server (/v1/extract): plain JSON request, no auth required.
- NIM API (/v1/chat/completions): OpenAI-compatible chat completions format, used by both the locally-run NIM container and the NVIDIA-hosted endpoint. Requires an API key for the hosted endpoint.
Parameters:
text
The text to analyze.
server_endpoint
The API endpoint URL.
enabled_entities
List of entity types to detect. If None, uses server defaults.
threshold
Confidence threshold for entity detection (0.0 to 1.0).
chunk_length
Length of text chunks for processing.
overlap
Overlap between chunks.
flat_ner
Whether to use flat NER mode.
api_key
Optional Bearer token for authenticated endpoints.
Returns: Dict[str, Any]
Normalized response dict with keys:
Raises:
ValueError: If the API call fails or the response cannot be parsed.