veil.entity_detectors.api

class veil.entity_detectors.api.HostedMaskerApiEntityDetector(cfg)[source]

Bases: MaskerApiEntityDetector

Anonymizer backed by a hosted Masker API. Wrapper around MaskerApiEntityDetector with specific entity types.

Parameters:

cfg (HostedMaskerApiEntityDetectorConfig)

ENTITY_TYPES: Set[EntityTypeBase] = {HostedMaskerApiEntityType.NAME, HostedMaskerApiEntityType.ADDRESS, HostedMaskerApiEntityType.COMPANY}
chunk_char_limit: int
chunk_on_truncation: bool
frequency_penalty: float
headers: Dict[str, str]
max_tokens: int
model: str | None
presence_penalty: float
retries: int
retry_backoff_base: float
retry_on_truncation: bool
system_prompt: str | None
temperature: float
timeout: float
top_k: int
top_p: float
truncation_min_fraction: float
class veil.entity_detectors.api.MaskerApiEntityDetector(cfg)[source]

Bases: BaseEntityDetector[EntityTypeBase]

Parameters:

cfg (MaskerApiEntityDetectorConfig)

ENTITY_TYPES: Set[EntityTypeBase]
detect_entities(doc)[source]

Detect entities by delegating to a remote masking API and parsing its masked output.

Parameters:

doc (Document)

Return type:

List[Span]

send_request(doc)[source]

Send request to the masking API and return the masked text.

Parameters:

doc (Document)

Return type:

str

send_request_with_retries(doc)[source]

Send request with retries and backoff. Returns (masked_text, truncated_flag).

Parameters:

doc (Document)

Return type:

Tuple[str, bool]