fix: wrap parsed moderation response in results object for LLM variations
This commit is contained in:
@@ -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)) {
|
||||
|
||||
Reference in New Issue
Block a user