fix schema
This commit is contained in:
@@ -58,4 +58,20 @@ content-type: application/json
|
|||||||
{
|
{
|
||||||
"url": "firecrawl.dev",
|
"url": "firecrawl.dev",
|
||||||
"sitemapOnly": true
|
"sitemapOnly": true
|
||||||
|
}
|
||||||
|
|
||||||
|
### Extract
|
||||||
|
# @name extract
|
||||||
|
POST {{baseUrl}}/v1/extract HTTP/1.1
|
||||||
|
Authorization: Bearer {{$dotenv TEST_API_KEY}}
|
||||||
|
content-type: application/json
|
||||||
|
|
||||||
|
{
|
||||||
|
"urls": ["firecrawl.dev"],
|
||||||
|
"prompt": "What is the title, description and main product of the page?",
|
||||||
|
"schema": {
|
||||||
|
"title": "string",
|
||||||
|
"description": "string",
|
||||||
|
"mainProduct": "string"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -108,6 +108,15 @@ export async function generateOpenAICompletions(logger: Logger, options: Extract
|
|||||||
required: ["items"],
|
required: ["items"],
|
||||||
additionalProperties: false,
|
additionalProperties: false,
|
||||||
};
|
};
|
||||||
|
} else if (schema && typeof schema === 'object' && !schema.type) {
|
||||||
|
schema = {
|
||||||
|
type: "object",
|
||||||
|
properties: Object.fromEntries(
|
||||||
|
Object.entries(schema).map(([key, value]) => [key, { type: value }])
|
||||||
|
),
|
||||||
|
required: Object.keys(schema),
|
||||||
|
additionalProperties: false
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
schema = normalizeSchema(schema);
|
schema = normalizeSchema(schema);
|
||||||
|
|||||||
Reference in New Issue
Block a user