Skip to content

Commit 2fb8a3c

Browse files
fix schema
1 parent 53134b7 commit 2fb8a3c

File tree

2 files changed

+25
-0
lines changed

2 files changed

+25
-0
lines changed

apps/api/requests.http

+16
Original file line numberDiff line numberDiff line change
@@ -58,4 +58,20 @@ content-type: application/json
5858
{
5959
"url": "firecrawl.dev",
6060
"sitemapOnly": true
61+
}
62+
63+
### Extract
64+
# @name extract
65+
POST {{baseUrl}}/v1/extract HTTP/1.1
66+
Authorization: Bearer {{$dotenv TEST_API_KEY}}
67+
content-type: application/json
68+
69+
{
70+
"urls": ["firecrawl.dev"],
71+
"prompt": "What is the title, description and main product of the page?",
72+
"schema": {
73+
"title": "string",
74+
"description": "string",
75+
"mainProduct": "string"
76+
}
6177
}

apps/api/src/scraper/scrapeURL/transformers/llmExtract.ts

+9
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,15 @@ export async function generateOpenAICompletions(logger: Logger, options: Extract
108108
required: ["items"],
109109
additionalProperties: false,
110110
};
111+
} else if (schema && typeof schema === 'object' && !schema.type) {
112+
schema = {
113+
type: "object",
114+
properties: Object.fromEntries(
115+
Object.entries(schema).map(([key, value]) => [key, { type: value }])
116+
),
117+
required: Object.keys(schema),
118+
additionalProperties: false
119+
};
111120
}
112121

113122
schema = normalizeSchema(schema);

0 commit comments

Comments
 (0)