From ea8d033af314b7db6ab5a5046f107208b5a39530 Mon Sep 17 00:00:00 2001 From: Phil <578330+philcluff@users.noreply.github.com> Date: Wed, 18 Feb 2026 11:40:02 +0000 Subject: [PATCH 1/2] Fix incorrect categories in Hive --- src/workflows/moderation.ts | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/src/workflows/moderation.ts b/src/workflows/moderation.ts index 9dbdb38..cbeeb6c 100644 --- a/src/workflows/moderation.ts +++ b/src/workflows/moderation.ts @@ -112,11 +112,10 @@ const DEFAULT_PROVIDER = "openai"; const HIVE_ENDPOINT = "https://api.thehive.ai/api/v2/task/sync"; const HIVE_SEXUAL_CATEGORIES = [ "general_nsfw", - "general_suggestive", "yes_sexual_activity", - "sex_toys", - "nudity_female", - "nudity_male", + "yes_sex_toy", + "yes_female_nudity", + "yes_male_nudity", ]; const HIVE_VIOLENCE_CATEGORIES = [ @@ -128,10 +127,8 @@ const HIVE_VIOLENCE_CATEGORIES = [ "hanging", "noose", "human_corpse", - "emaciated_body", - "self_harm", - "animal_abuse", - "fights", + "yes_emaciated_body", + "yes_self_harm", "garm_death_injury_or_military_conflict", ]; From c3d43eb27c2d02c46249d1e0a43f6b810373785f Mon Sep 17 00:00:00 2001 From: Phil <578330+philcluff@users.noreply.github.com> Date: Wed, 18 Feb 2026 11:56:17 +0000 Subject: [PATCH 2/2] Add testing and logging --- src/workflows/moderation.ts | 10 ++++++++-- tests/unit/moderation.test.ts | 31 +++++++++++++++++++++++++++++++ 2 files changed, 39 insertions(+), 2 deletions(-) create mode 100644 tests/unit/moderation.test.ts diff --git a/src/workflows/moderation.ts b/src/workflows/moderation.ts index cbeeb6c..8266b80 100644 --- a/src/workflows/moderation.ts +++ b/src/workflows/moderation.ts @@ -110,7 +110,7 @@ const DEFAULT_THRESHOLDS = { const DEFAULT_PROVIDER = "openai"; const HIVE_ENDPOINT = "https://api.thehive.ai/api/v2/task/sync"; -const HIVE_SEXUAL_CATEGORIES = [ +export const HIVE_SEXUAL_CATEGORIES = [ "general_nsfw", "yes_sexual_activity", "yes_sex_toy", @@ -118,7 +118,7 @@ const HIVE_SEXUAL_CATEGORIES = [ "yes_male_nudity", ]; -const HIVE_VIOLENCE_CATEGORIES = [ +export const HIVE_VIOLENCE_CATEGORIES = [ "gun_in_hand", "gun_not_in_hand", "knife_in_hand", @@ -322,6 +322,12 @@ function getHiveCategoryScores( const scoreMap = Object.fromEntries( classes.map(c => [c.class, c.score]), ); + const missingCategories = categoryNames.filter(category => !(category in scoreMap)); + if (missingCategories.length > 0) { + console.warn( + `Hive response missing expected categories: ${missingCategories.join(", ")}`, + ); + } const scores = categoryNames.map(category => scoreMap[category] || 0); return Math.max(...scores, 0); } diff --git a/tests/unit/moderation.test.ts b/tests/unit/moderation.test.ts new file mode 100644 index 0000000..a576c73 --- /dev/null +++ b/tests/unit/moderation.test.ts @@ -0,0 +1,31 @@ +import { describe, expect, it } from "vitest"; + +import { HIVE_SEXUAL_CATEGORIES, HIVE_VIOLENCE_CATEGORIES } from "../../src/workflows/moderation"; + +describe("hive moderation categories", () => { + it("the HIVE_SEXUAL_CATEGORIES has not changed — If you change these, remember to check that these are accurate categories in Hive!", () => { + expect(HIVE_SEXUAL_CATEGORIES).toEqual([ + "general_nsfw", + "yes_sexual_activity", + "yes_sex_toy", + "yes_female_nudity", + "yes_male_nudity", + ]); + }); + + it("the HIVE_VIOLENCE_CATEGORIES has not changed — If you change these, remember to check that these are accurate categories in Hive!", () => { + expect(HIVE_VIOLENCE_CATEGORIES).toEqual([ + "gun_in_hand", + "gun_not_in_hand", + "knife_in_hand", + "very_bloody", + "other_blood", + "hanging", + "noose", + "human_corpse", + "yes_emaciated_body", + "yes_self_harm", + "garm_death_injury_or_military_conflict", + ]); + }); +});