diff options
| author | Fuwn <[email protected]> | 2025-09-26 02:30:31 -0700 |
|---|---|---|
| committer | Fuwn <[email protected]> | 2025-09-26 02:30:31 -0700 |
| commit | 6d0ee2b9f1bfdedbe7ee020c5240960f0d631fee (patch) | |
| tree | 62041f09c9bdef1ae99c4df076100a061324bc4a /packages/gateway | |
| parent | refactor(gateway:moderationAgent): Switch to OpenRouter API (diff) | |
| download | umabotdiscord-6d0ee2b9f1bfdedbe7ee020c5240960f0d631fee.tar.xz umabotdiscord-6d0ee2b9f1bfdedbe7ee020c5240960f0d631fee.zip | |
feat(gateway:moderationAgent): Switch model to Microsoft: Phi 4 Multimodal Instruct
Diffstat (limited to 'packages/gateway')
| -rw-r--r-- | packages/gateway/src/listeners/moderationAgent/constants.ts | 2 | ||||
| -rw-r--r-- | packages/gateway/src/listeners/moderationAgent/utilities.ts | 18 |
2 files changed, 18 insertions, 2 deletions
diff --git a/packages/gateway/src/listeners/moderationAgent/constants.ts b/packages/gateway/src/listeners/moderationAgent/constants.ts index f91627e..969ca19 100644 --- a/packages/gateway/src/listeners/moderationAgent/constants.ts +++ b/packages/gateway/src/listeners/moderationAgent/constants.ts @@ -8,7 +8,7 @@ export const MIN_MESSAGE_LENGTH = 15; export const MAX_SYMBOL_DENSITY = 0.6; export const MAX_COMPLETION_TOKENS = 2000; export const MESSAGE_HISTORY_SIZE = 0; -export const MODEL = "gpt-5-nano"; +export const MODEL = "microsoft/phi-4-multimodal-instruct"; export const SAFE_WORDS = new Set([ "hello", "hi", diff --git a/packages/gateway/src/listeners/moderationAgent/utilities.ts b/packages/gateway/src/listeners/moderationAgent/utilities.ts index b5c0530..eb55f1c 100644 --- a/packages/gateway/src/listeners/moderationAgent/utilities.ts +++ b/packages/gateway/src/listeners/moderationAgent/utilities.ts @@ -169,7 +169,23 @@ UNDERAGE CONTENT RULES: } try { - return JSON.parse(content); + let jsonContent = content; + + if (content.startsWith("```json")) { + if (content.endsWith("```")) { + jsonContent = content.slice(7, -3).trim(); + } else { + jsonContent = content.slice(7).trim(); + } + } else if (content.startsWith("```")) { + if (content.endsWith("```")) { + jsonContent = content.slice(3, -3).trim(); + } else { + jsonContent = content.slice(3).trim(); + } + } + + return JSON.parse(jsonContent); } catch (parseError) { console.error("Failed to parse OpenRouter response as JSON:", content); console.error("Parse error:", parseError); |