संयुक्त मल्टी-चेक अनुरोध
हर चेक के लिए अलग API कॉल की ज़रूरत नहीं है। एक ही POST /api/v2/check मिश्रित सामग्री पर text, image, badword, और antivirus चेक साथ-साथ चला सकता है, और हर एक के परिणाम के साथ एक ही प्रतिक्रिया लौटा सकता है। किसी ऐसी पोस्ट को मॉडरेट करने का यह सबसे कुशल तरीका है जिसमें caption, image, और attachment सब एक साथ हों।
सब कुछ एक ही कॉल में मॉडरेट क्यों करें?
यूज़र का सबमिशन आम तौर पर एक पैकेज होता है: text के साथ media और links। हर हिस्से के लिए API को अलग-अलग कॉल करने का मतलब है ज़्यादा round trips, ज़्यादा latency, और ज़्यादा quota खर्च। एक संयुक्त अनुरोध enabled checks को समानांतर में चलाता है और आपको कार्रवाई के लिए एक ही verdict देता है।
मैं एक साथ कई चेक कैसे चलाऊँ?
हर तरह की सामग्री को content में रखें, जिन checks की ज़रूरत हो उन्हें settings में enable करें, और हर check के अलग-अलग परिणाम पढ़ें। हर enabled check मिलती-जुलती सामग्री पर चलता है।
curl -X POST https://api.discuse.com/api/v2/check \
-H "Content-Type: application/json" \
-H "X-API-Key: YOUR_API_KEY" \
-d '{
"content": {
"text": "Great deal, check my profile!",
"image_urls": ["https://example.com/post-image.jpg"],
"document_urls": ["https://example.com/attachment.pdf"]
},
"settings": {
"check_spam": true,
"check_sentiment": true,
"check_images": true,
"check_antivirus": true
}
}'
प्रतिक्रिया
{
"has_violations": true,
"cached": false,
"results": {
"hits": true,
"spamfinder": { "label": "spam", "confidence": 0.91, "is_spam": true, "hit": true },
"sentiment": { "is_negative": false, "is_toxic": false, "score": 0.1, "hit": false },
"images": { "status": "OK", "porn": 0.02, "sexual": 0.05, "neutral": 0.93, "hit": false },
"antivirus": { "status": "OK", "hit": false, "details": [] }
},
"usage": {
"api_requests_used": 530,
"api_requests_limit": 10000,
"api_requests_remaining": 9470
}
}
संयुक्त परिणाम को कैसे पढ़ूँ?
कुल निर्णय के लिए has_violations का उपयोग करें, फिर यह देखने के लिए हर results.<check>.hit देखें कि कौन-सा check triggered हुआ और क्यों:
| फ़ील्ड | अर्थ |
|---|---|
has_violations |
अगर किसी भी enabled check ने सामग्री को flag किया है तो True — आपका एक-पंक्ति verdict |
results.hits |
results object के अंदर वही कुल signal |
results.spamfinder.hit |
Spam fired (threshold-aware; raw is_spam नहीं, hit पर gate करें) |
results.sentiment.hit |
आपके thresholds से ऊपर toxic/negative sentiment |
results.images.hit |
कोई image आपके NSFW threshold से ऊपर थी |
results.antivirus.hit |
किसी document में malware मिला |
results.badwords.hit |
configured badword match हुआ |
results.skipped_features |
वे checks जिनका अनुरोध किया गया था लेकिन चलाए नहीं गए (जैसे कोई feature जिसका quota समाप्त हो गया हो) |
केवल वे checks जिन्हें आपने enable किया है (और जिनके लिए मिलती-जुलती सामग्री मौजूद थी) results में दिखाई देते हैं। जिस check के पास कार्रवाई करने के लिए कोई content नहीं है — जैसे image_urls के बिना check_images — वह बस नहीं चलता।
कौन-सी सामग्री किस check के साथ जाती है?
| चेक | यह जो सामग्री पढ़ता है |
|---|---|
check_sentiment, check_spam, check_badwords, check_language |
content.text |
check_images |
content.image_urls |
check_antivirus |
content.document_urls |
एक ही अनुरोध में अधिकतम 10 image URLs, 5 document URLs, और 10,000 characters तक का text भेजा जा सकता है। किसी submission के हिस्सों को calls में बाँटने के बजाय साथ में भेजें।
आंशिक विफलताओं के बारे में क्या?
अगर किसी एक check में error आता है (मान लें कोई image URL पहुँच से बाहर है), तो बाकी checks फिर भी लौटते हैं — आपको सफल हुए परिणाम मिलते हैं, और failed check पूरे अनुरोध को fail करने के बजाय अपना error/empty result रिपोर्ट करता है। हर check के हिसाब से निर्णय लें: confirmed hit पर block करें, और तय करें कि errored check को fail open करना है या review के लिए queue में डालना है।
सर्वोत्तम अभ्यास
केवल वही enable करें जिसकी ज़रूरत है
हर enabled check काम बढ़ाता है। वे checks चालू करें जो आपको वास्तव में मिलने वाली सामग्री से मेल खाते हैं — केवल text वाले messages पर check_antivirus चलाने का कोई लाभ नहीं है।
पहले एक verdict, फिर विस्तार से देखें
fast path के लिए पहले has_violations पर branch करें, फिर results को केवल तब inspect करें जब आपको यह जानना हो कि कौन-सा check triggered हुआ (logging, appeals, या सही reviewer तक routing के लिए)।
const res = await check(content, settings);
if (!res.has_violations) return allow();
const r = res.results;
if (r.antivirus?.hit) return quarantine(); // most severe first
if (r.images?.hit) return blockMedia();
if (r.spamfinder?.hit || r.badwords?.hit) return shadowban();
return queueForReview(r);
संबंधित
- Text Analysis — sentiment, spam, और text result fields
- Image NSFW Detection — image scoring और thresholds
- File Antivirus Scanning — document malware checks
- Error and Response Codes — response envelope और quota handling