mirror of
https://github.com/mendableai/firecrawl.git
synced 2024-11-16 11:42:24 +08:00
fix(scrapeURL/llmExtract): better schema normalization
This commit is contained in:
parent
1c55ce41be
commit
e97864b806
|
@ -19,6 +19,28 @@ export class LLMRefusalError extends Error {
|
||||||
}
|
}
|
||||||
|
|
||||||
function normalizeSchema(x: any): any {
|
function normalizeSchema(x: any): any {
|
||||||
|
if (typeof x !== "object" || x === null) return x;
|
||||||
|
|
||||||
|
if (x["$defs"] !== null && typeof x["$defs"] === "object") {
|
||||||
|
x["$defs"] = Object.fromEntries(Object.entries(x["$defs"]).map(([name, schema]) => [name, normalizeSchema(schema)]));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (x && x.anyOf) {
|
||||||
|
x.anyOf = x.anyOf.map(x => normalizeSchema(x));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (x && x.oneOf) {
|
||||||
|
x.oneOf = x.oneOf.map(x => normalizeSchema(x));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (x && x.allOf) {
|
||||||
|
x.allOf = x.allOf.map(x => normalizeSchema(x));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (x && x.not) {
|
||||||
|
x.not = normalizeSchema(x.not);
|
||||||
|
}
|
||||||
|
|
||||||
if (x && x.type === "object") {
|
if (x && x.type === "object") {
|
||||||
return {
|
return {
|
||||||
...x,
|
...x,
|
||||||
|
|
Loading…
Reference in New Issue
Block a user