fix: wrap parsed moderation response in results object for LLM variations

This commit is contained in:
MythEclipse
2026-05-18 07:12:41 +07:00
parent 5411f8ea3d
commit 9d5559a45b
+6 -1
View File
@@ -76,7 +76,12 @@ export function parseModerationResponse(
targetIds: string[],
): AnalysisResult[] {
// Extract and parse JSON object
const parsed = extractJson(content);
let parsed = extractJson(content);
// If parsed is a direct array, wrap it in a results object to handle LLM variations
if (Array.isArray(parsed)) {
parsed = { results: parsed };
}
// Validate structure
if (!parsed || typeof parsed !== "object" || !("results" in parsed)) {