fix schema

This commit is contained in:
rafaelmmiller 2024-11-19 10:04:42 -03:00
parent 53134b7c85
commit 2fb8a3c8dc
2 changed files with 25 additions and 0 deletions

View File

@ -58,4 +58,20 @@ content-type: application/json
{
"url": "firecrawl.dev",
"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"
}
}

View File

@ -108,6 +108,15 @@ export async function generateOpenAICompletions(logger: Logger, options: Extract
required: ["items"],
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);