Check source code for matches against public code repositories using the
Azure AI Content Safety protected-material-for-code detector. This is the
code counterpart to foundry_protected_material(), useful for flagging
LLM-generated code that reproduces licensed material.
Usage
foundry_protected_code(
code,
endpoint = NULL,
api_key = NULL,
api_version = "2024-09-15-preview"
)Arguments
- code
Character vector. One or more code snippets to check.
- endpoint
Character. Optional Content Safety endpoint. Defaults to the
AZURE_CONTENT_SAFETY_ENDPOINTenvironment variable.- api_key
Character. Optional Content Safety key. Defaults to the
AZURE_CONTENT_SAFETY_KEYenvironment variable.- api_version
Character. API version. Defaults to
"2024-09-15-preview".
Value
A tibble with one row per input snippet:
- code
Character. The input snippet.
- detected
Logical.
TRUEwhen protected material was detected.- citations
List. A tibble of
licenseandsource_urlsfor each matched code citation.- raw_response
List. The parsed API response.