ai-excluder-v1
v1.0.0
Published
Hybrid AI‑content detection and exclusion SDK for feeds, search results, and apps.
Readme
AI Excluder v1
Hybrid AI‑content detection and exclusion SDK for feeds, search results, and apps.
Install
npm install ai-excluder-v1Node.js v20+ is recommended for best compatibility. (Current dev env is on v18; upgrade via nvm install 20.)
Quick start
const { AIExcluder } = require('ai-excluder-v1');
const excluder = new AIExcluder().init({
threshold: 0.6,
onExclude: (item, res) => console.log('Excluded', item.id, res.confidence),
});
const items = [
{ id: 1, type: 'text', content: 'As an AI language model...' },
{ id: 2, type: 'text', content: 'I wrote this myself.' },
];
const filtered = await excluder.filterContent(items);
console.log(filtered);Direct detector usage:
const { detectAI } = require('ai-excluder-v1');
const res = await detectAI('Some text', 'text');
// => { isAI: boolean, confidence: number }API
detectAI(content, type, options?)
content: string for text,tf.Tensor3Dfor images, or{ text, image, metadata }for hybrid.type:'text' | 'image' | 'hybrid'.options.threshold: override detection threshold.options.metadata: optional metadata string for watermark checks.
Returns { isAI, confidence } (0–1).
class AIExcluder
init(options)threshold: default decision threshold.storage: optional persistent storage (defaults tolocalStoragein browser or memory in Node).prefs: initial preferences override.onExclude(item, res): callback when an item is excluded.
getPrefs()/setPrefs(partial)- Preferences:
excludeAI,excludeTextOnly,excludeImagesOnly,threshold.
- Preferences:
filterContent(items)- Filters an array of items, excluding those flagged as AI.
bindToggle(element, onChange?)- Plain JS: attach click handler to toggle AI exclusion.
withAIExclusion(Component)- React HOC: wraps a component that receives
itemsprop.
- React HOC: wraps a component that receives
Demos
Web demo:
npm run demo:webOpen
http://localhost:3000and toggle exclusion.React demo:
npm run demo:reactDemo lives in
demos/react/react-demo.
Limitations
- Detection is hybrid and heuristic‑heavy in v1; false positives/negatives are possible.
- Text ML uses
roberta-base-openai-detectorvia@xenova/transformersand downloads on first use. - Image detection is best‑effort unless a stronger fine‑tuned model is plugged in.
See feedback.md for planned improvements.
License
MIT. See LICENSE.
