Handle object-shaped changed sections
This commit is contained in:
@@ -4,6 +4,7 @@ import {
|
||||
articleInputSchema,
|
||||
confirmedFactCardSchema,
|
||||
candidateFactCardSchema,
|
||||
optimizedArticleSchema,
|
||||
qaReportSchema,
|
||||
} from "../validation";
|
||||
|
||||
@@ -144,4 +145,23 @@ describe("domain validation", () => {
|
||||
}),
|
||||
).toThrow();
|
||||
});
|
||||
|
||||
it("normalizes object-shaped changed sections from LLM output", () => {
|
||||
const parsed = optimizedArticleSchema.parse({
|
||||
title: "Optimized article",
|
||||
summary: "Summary constrained by the confirmed fact card.",
|
||||
body_markdown: "## Body\nUpdated body.",
|
||||
image_suggestions: [],
|
||||
changed_sections: [
|
||||
{ section: "title", change: "Improved keyword clarity." },
|
||||
{ name: "body", reason: "Fixed sentence flow." },
|
||||
],
|
||||
requires_user_confirmation: [],
|
||||
});
|
||||
|
||||
expect(parsed.changed_sections).toEqual([
|
||||
"title: Improved keyword clarity.",
|
||||
"body: Fixed sentence flow.",
|
||||
]);
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user