SShortSingh.
Back to feed

Developer Builds Two-Stage AI Content Moderation Classifier Using Python and Telnyx

0
·1 views

A developer has published an open-source Python Flask application that performs AI-powered content moderation using a two-stage pipeline. The system first uses embedding-based similarity to quickly filter content against a known-bad blocklist, and only escalates to a large language model when no strong blocklist match is found. Built on Telnyx AI Inference, the app uses the Kimi-K2 model for judgment calls and the gte-large model for embeddings. It supports single and batch moderation of up to 20 items, returning structured outputs such as category, confidence score, and a recommended action like allow, flag, or remove. The author notes that a production-ready version would require additions such as persistent storage, audit logging, human review queues, and a feedback loop for tuning thresholds over time.

Read the full story at DEV Community

This is an AI-generated summary. ShortSingh links to the original source for the complete article.

Discussion (0)

Log in to join the discussion and vote.

Log in

Related stories

0
ProgrammingDEV Community ·

How UUID v7 fixes B-tree index scatter and the same-millisecond ordering trap

UUID v4 generates random values that scatter across database indexes, causing frequent B-tree page splits and poor insert performance. UUID v7, standardized in RFC 9562, embeds a 48-bit millisecond Unix timestamp in its leading bits, ensuring generated IDs sort in creation order and preserving index locality. A developer building a browser-only UUID generator implemented v7 by hand, noting that JavaScript's 32-bit bitwise operators mangle 48-bit timestamps, making division-based bit extraction necessary instead of shift operators. A key pitfall arises when multiple IDs are generated within the same millisecond, since their leading bits are identical and relative ordering becomes random, silently breaking any strict-ascending assumption. For use cases requiring guaranteed monotonicity, the 12-bit rand_a field can serve as an incrementing counter within the same millisecond, resetting to a random seed when the millisecond advances.

0
ProgrammingDEV Community ·

Developer builds expiry-aware static site system to auto-hide outdated deals

A developer managing multiple deal-listing websites built a data-driven system to handle time-limited content such as Kindle manga sales and grocery offers. Each article stores a deadline field in its JSON data, and a build script calculates days remaining at site-generation time rather than relying on manual removal. A key design choice was using the article's last verification date as the reference point, not the current date, to avoid asserting facts that were never re-checked. The system labels content as 'may have ended' once past its deadline, and filters rather than deletes expired entries to preserve existing URLs. The approach also accounts for timezone parsing issues in JavaScript, pinning dates to JST to prevent off-by-one errors.

0
ProgrammingDEV Community ·

Developer builds emoji-blocking lint that halts automated site builds on violation

A developer managing roughly twenty automated static sites found that machine-generated content repeatedly introduced emoji despite a strict no-emoji style rule. To enforce the policy reliably, they built a custom linter that scans output files using a Unicode regex and exits with a non-zero code if any emoji is detected, halting the rest of the build pipeline. The tool reports findings as JSON with file names and line numbers, making violations easy to locate and fix. A silent bug initially caused the linter to scan zero files and falsely report success, which was traced to a mismatch between how file extensions were passed as arguments versus how they were compared internally. The fix involved normalising extension inputs to include a leading dot, and the developer noted that logging the number of files scanned would have exposed the empty-scan issue much sooner.

0
ProgrammingDEV Community ·

How Next.js Edge Caching Causes Stale Pages and How to Fix It

Next.js uses aggressive edge caching for statically prerendered pages, setting a Cache-Control s-maxage of one year, which can cause listing pages to appear outdated even after content updates. A developer noticed this when their article listing page failed to reflect new posts, while individual article pages updated normally due to dynamic rendering or revalidation settings. The root cause is not a bug but intended Next.js App Router behavior, where shared cache headers override browser-level cache controls. Developers can address this by adding a revalidate export to the page file, which triggers background regeneration at a set interval after the cache expires. For immediate updates, Next.js also offers on-demand revalidation via the revalidatePath function, which can be called from a CMS webhook or API route to instantly invalidate a cached page.

Developer Builds Two-Stage AI Content Moderation Classifier Using Python and Telnyx · ShortSingh