PowerShell ile Azure AI Content Safety Moderasyon
Azure AI Content Safety, zararlı içerikleri tespit etmek için gelişmiş AI modelleri kullanır. PowerShell ile metin ve görüntü moderasyonunu uygulamalarınıza entegre edebilirsiniz.
Content Safety Servisi Oluşturmak
$rg = "newrg-"
$csName = "myContentSafety"
$location = "uksouth"
New-AzCognitiveServicesAccount -ResourceGroupName $rg -Name $csName `
-Type ContentSafety -SkuName S0 -Location $location
$apiKey = (Get-AzCognitiveServicesAccountKey -ResourceGroupName $rg -Name $csName).Key1
Write-Host "Content Safety servisi hazır."

Metin Moderasyonu Yapmak
$endpoint = "https://mycontentsafety-26e9d.cognitiveservices.azure.com/contentsafety/text:analyze?api-version=2024-09-01"
$headers = @{ "Ocp-Apim-Subscription-Key" = $apiKey; "Content-Type" = "application/json" }
function Test-ContentSafety {
param([string]$Text)
$body = @{
text = "$text"
categories = @("Hate","SelfHarm","Sexual","Violence")
outputType = "FourSeverityLevels"
} | ConvertTo-Json
$result = Invoke-RestMethod -Uri $endpoint -Method Post -Headers $headers -Body $body
return $result.categoriesAnalysis
}
$analysis = Test-ContentSafety -Text "Bu bir test mesajıdır."
$analysis | ForEach-Object {
$safe = $_.severity -eq 0
$color = if ($safe) { "Green" } else { "Red" }
Write-Host "$($_.category): Seviye $($_.severity)" -ForegroundColor $color
}
test 1

test 2































































































