fix(confidence-engine): handle propertyless openai object schemas
This commit is contained in:
@@ -220,6 +220,7 @@ describe("OpenAI reconstruction provider experiment seam", () => {
|
||||
const resolved = resolveLocalRef(schema, root);
|
||||
if (resolved?.properties) {
|
||||
expect(resolved.required).toEqual(Object.keys(resolved.properties));
|
||||
expect(resolved.additionalProperties).toBe(false);
|
||||
Object.values(resolved.properties).forEach((property) => assertAllPropertiesRequired(property, root));
|
||||
}
|
||||
(resolved?.anyOf ?? []).forEach((branch) => assertAllPropertiesRequired(branch, root));
|
||||
@@ -337,7 +338,9 @@ describe("OpenAI reconstruction provider experiment seam", () => {
|
||||
"possibleFollowUpQuestions",
|
||||
]);
|
||||
expect(Object.keys(schema.properties)).toEqual(schema.required);
|
||||
expect(schema.additionalProperties).toBe(false);
|
||||
expect(schema.properties).toHaveProperty("targetNodeId");
|
||||
expect(schema.properties.relationships.items.additionalProperties).toBe(false);
|
||||
expect(schema.properties).not.toHaveProperty("reconstruction");
|
||||
expect(schema.properties).not.toHaveProperty("inputClassification");
|
||||
expect(result.response).toEqual({
|
||||
@@ -350,6 +353,46 @@ describe("OpenAI reconstruction provider experiment seam", () => {
|
||||
});
|
||||
});
|
||||
|
||||
it("recursively projects arbitrary nested object schemas as strict", () => {
|
||||
const alternateSchema = {
|
||||
type: "object",
|
||||
properties: {
|
||||
groups: {
|
||||
type: "array",
|
||||
items: {
|
||||
type: "object",
|
||||
properties: {
|
||||
details: {
|
||||
type: "object",
|
||||
properties: { value: { type: "string" } },
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
const projected = createOpenAIStrictSchema(alternateSchema, null);
|
||||
|
||||
expect(projected.additionalProperties).toBe(false);
|
||||
expect(projected.properties.groups.items.additionalProperties).toBe(false);
|
||||
expect(projected.properties.groups.items.properties.details.additionalProperties).toBe(false);
|
||||
});
|
||||
|
||||
it("projects property-less objects nested in arrays as strict", () => {
|
||||
const projected = createOpenAIStrictSchema({
|
||||
type: "object",
|
||||
properties: {
|
||||
relationships: { type: "array", items: { type: "object" } },
|
||||
},
|
||||
}, null);
|
||||
|
||||
expect(projected.properties.relationships.items).toEqual({
|
||||
type: "object",
|
||||
additionalProperties: false,
|
||||
});
|
||||
});
|
||||
|
||||
it("extracts ordered output_text parts from raw Responses output", async () => {
|
||||
const provider = createOpenAIReconstructionProvider({
|
||||
apiKey: "test-key",
|
||||
|
||||
Reference in New Issue
Block a user