Nick: extract fixes

This commit is contained in:
Nicolas 2024-11-20 11:50:14 -08:00
parent c9b0a80522
commit d49f62fb56
2 changed files with 5 additions and 2 deletions

View File

@ -86,7 +86,8 @@ describe("E2E Tests for Extract API Routes", () => {
type: "array", type: "array",
items: { items: {
type: "string" type: "string"
} },
required: ["items"]
}, },
}); });
expect(response.statusCode).toBe(200); expect(response.statusCode).toBe(200);

View File

@ -165,7 +165,9 @@ export async function generateOpenAICompletions(logger: Logger, options: Extract
} }
} }
if (options.schema && options.schema.type === "array") { // If the users actually wants the items object, they can specify it as 'required' in the schema
// otherwise, we just return the items array
if (options.schema && options.schema.type === "array" && !schema?.required?.includes("items")) {
extract = extract?.items; extract = extract?.items;
} }
return { extract, warning }; return { extract, warning };