Chuyển đến nội dung
Skillpedia
Agent48k · #3882

azure-ai-contentsafety-ts

Skill này làm gì

Dịch vụ này kiểm tra văn bản và hình ảnh xem có nội dung có hại như ngôn từ thù ghét, nội dung tình dục, bạo lực hoặc tự làm hại bản thân. Nó cũng cho phép bạn tạo danh sách các từ hoặc cụm từ bị cấm.

Khi nào nên dùng

  • ✓Khi bạn kiểm duyệt bình luận trên website.
  • ✓Khi bạn kiểm tra văn bản hoặc hình ảnh có an toàn trước khi đăng tải.
  • ✓Khi bạn tạo danh sách các từ không nên xuất hiện trong nội dung.

Liên kết skill

https://github.com/sickn33/agentic-awesome-skills/blob/main/plugins/agentic-awesome-skills-claude/skills/azure-ai-contentsafety-ts/SKILL.md

Sao chép rồi dán vào AI của bạn (Claude, ChatGPT hoặc Cursor) và nhờ nó làm theo hướng dẫn.

Cách dùng

Cách dễ nhất: sao chép tin nhắn và dán vào AI của bạn. AI sẽ đọc skill và làm theo hướng dẫn.

Tin nhắn có sẵn để dán

Hãy dùng skill này để giúp tôi: https://github.com/sickn33/agentic-awesome-skills/blob/main/plugins/agentic-awesome-skills-claude/skills/azure-ai-contentsafety-ts/SKILL.md Đọc tệp SKILL.md tại liên kết đó và làm theo hướng dẫn cho việc của tôi.
Bạn muốn AI tự tìm những skill như thế này?Cài MCP Skillpedia miễn phí: chỉ một dòng, và AI sẽ tìm trong 15.000+ skill trước mỗi việc.Cài đặt trong 1 phút →

Ví dụ cách nhờ AI

“Kiểm tra văn bản này: 'Sự kiện đã bị hủy vì có những lời đe dọa bạo lực.'”

5 skill mới mỗi tuần. Đọc chỉ 1 phút.

Cách hoạt động

Bạn gửi văn bản hoặc hình ảnh tới dịch vụ. Nó phân tích nội dung và cho bạn biết có điều gì có hại hay không cùng mức độ nghiêm trọng. Bạn có thể thêm các từ bị cấm riêng để kiểm tra được cá nhân hóa hơn.

Nội dung kỹ thuật (SKILL.md gốc)

Lấy nguyên văn từ GitHub, do tác giả viết bằng tiếng Anh.

Azure AI Content Safety REST SDK for TypeScript

Analyze text and images for harmful content with customizable blocklists.

Installation

npm install @azure-rest/ai-content-safety @azure/identity @azure/core-auth

Environment Variables

CONTENT_SAFETY_ENDPOINT=https://<resource>.cognitiveservices.azure.com
CONTENT_SAFETY_KEY=<api-key>

Authentication

Important: This is a REST client. ContentSafetyClient is a function, not a class.

API Key

import ContentSafetyClient from "@azure-rest/ai-content-safety";
import { AzureKeyCredential } from "@azure/core-auth";

const client = ContentSafetyClient(
  process.env.CONTENT_SAFETY_ENDPOINT!,
  new AzureKeyCredential(process.env.CONTENT_SAFETY_KEY!)
);

DefaultAzureCredential

import ContentSafetyClient from "@azure-rest/ai-content-safety";
import { DefaultAzureCredential } from "@azure/identity";

const client = ContentSafetyClient(
  process.env.CONTENT_SAFETY_ENDPOINT!,
  new DefaultAzureCredential()
);

Analyze Text

import ContentSafetyClient, { isUnexpected } from "@azure-rest/ai-content-safety";

const result = await client.path("/text:analyze").post({
  body: {
    text: "Text content to analyze",
    categories: ["Hate", "Sexual", "Violence", "SelfHarm"],
    outputType: "FourSeverityLevels"  // or "EightSeverityLevels"
  }
});

if (isUnexpected(result)) {
  throw result.body;
}

for (const analysis of result.body.categoriesAnalysis) {
  console.log(`${analysis.category}: severity ${analysis.severity}`);
}

Analyze Image

Base64 Content

import { readFileSync } from "node:fs";

const imageBuffer = readFileSync("./image.png");
const base64Image = imageBuffer.toString("base64");

const result = await client.path("/image:analyze").post({
  body: {
    image: { content: base64Image }
  }
});

if (isUnexpected(result)) {
  throw result.body;
}

for (const analysis of result.body.categoriesAnalysis) {
  console.log(`${analysis.category}: severity ${analysis.severity}`);
}

Blob URL

const result = await client.path("/image:analyze").post({
  body: {
    image: { blobUrl: "https://storage.blob.core.windows.net/container/image.png" }
  }
});

Blocklist Management

Create Blocklist

const result = await client
  .path("/text/blocklists/{blocklistName}", "my-blocklist")
  .patch({
    contentType: "application/merge-patch+json",
    body: {
      description: "Custom blocklist for prohibited terms"
    }
  });

if (isUnexpected(result)) {
  throw result.body;
}

console.log(`Created: ${result.body.blocklistName}`);

Add Items to Blocklist

const result = await client
  .path("/text/blocklists/{blocklistName}:addOrUpdateBlocklistItems", "my-blocklist")
  .post({
    body: {
      blocklistItems: [
        { text: "prohibited-term-1", description: "First blocked term" },
        { text: "prohibited-term-2", description: "Second blocked term" }
      ]
    }
  });

if (isUnexpected(result)) {
  throw result.body;
}

for (const item of result.body.blocklistItems ?? []) {
  console.log(`Added: ${item.blocklistItemId}`);
}

Analyze with Blocklist

const result = await client.path("/text:analyze").post({
  body: {
    text: "Text that might contain blocked terms",
    blocklistNames: ["my-blocklist"],
    haltOnBlocklistHit: false
  }
});

if (isUnexpected(result)) {
  throw result.body;
}

// Check blocklist matches
if (result.body.blocklistsMatch) {
  for (const match of result.body.blocklistsMatch) {
    console.log(`Blocked: "${match.blocklistItemText}" from ${match.blocklistName}`);
  }
}

List Blocklists

const result = await client.path("/text/blocklists").get();

if (isUnexpected(result)) {
  throw result.body;
}

for (const blocklist of result.body.value ?? []) {
  console.log(`${blocklist.blocklistName}: ${blocklist.description}`);
}

Delete Blocklist

await client.path("/text/blocklists/{blocklistName}", "my-blocklist").delete();

Harm Categories

Category API Term Description
Hate and Fairness Hate Discriminatory language targeting identity groups
Sexual Sexual Sexual content, nudity, pornography
Violence Violence Physical harm, weapons, terrorism
Self-Harm SelfHarm Self-injury, suicide, eating disorders

…

Câu hỏi thường gặp

Dịch vụ phát hiện những loại nội dung có hại nào?

Nó phát hiện ngôn từ thù ghét, nội dung tình dục, bạo lực và tự làm hại bản thân.

“Blocklists” là gì?

Đó là các danh sách do bạn tạo, gồm những từ hoặc cụm từ cụ thể mà bạn muốn cấm xuất hiện trong nội dung.

Làm sao để biết nội dung có thực sự có hại không?

Dịch vụ gán mức độ nghiêm trọng (từ 0 đến 6) cho mỗi nhóm nội dung có hại được phát hiện. Mức càng cao thì rủi ro càng lớn.

Chi tiết

Mô tả gốc của tác giả

Analyze text and images for harmful content with customizable blocklists.

repo: sickn33/agentic-awesome-skills

Độ phổ biến

Sao GitHub
48k
Vị trí xếp hạng
#3882
Giấy phép
MIT
Cập nhật
15/10/2026

Skill này có hữu ích không?

0

Đăng nhập để bình chọn.

Bình luận

  • …

Thêm skill từ kho mã này

Skill tương tự