mirror of
https://git.mirrors.martin98.com/https://github.com/mendableai/firecrawl
synced 2025-08-12 07:29:04 +08:00
correlate with eid
This commit is contained in:
parent
512a2b1cd4
commit
80b507e64e
@ -22,6 +22,7 @@ type BatchExtractOptions = {
|
||||
systemPrompt: string;
|
||||
doc: Document;
|
||||
useAgent: boolean;
|
||||
extractId?: string;
|
||||
};
|
||||
|
||||
/**
|
||||
@ -44,7 +45,7 @@ export async function batchExtractPromise(options: BatchExtractOptions, logger:
|
||||
smartScrapeCallCount: number;
|
||||
otherCallCount: number;
|
||||
}> {
|
||||
const { multiEntitySchema, links, prompt, systemPrompt, doc, useAgent } = options;
|
||||
const { multiEntitySchema, links, prompt, systemPrompt, doc, useAgent, extractId } = options;
|
||||
|
||||
|
||||
const generationOptions: GenerateCompletionsOptions = {
|
||||
@ -74,6 +75,7 @@ export async function batchExtractPromise(options: BatchExtractOptions, logger:
|
||||
extractOptions: generationOptions,
|
||||
urls: [doc.metadata.sourceURL || doc.metadata.url || ""],
|
||||
useAgent,
|
||||
extractId,
|
||||
});
|
||||
extractedDataArray = e;
|
||||
warning = w;
|
||||
|
@ -14,7 +14,8 @@ export async function singleAnswerCompletion({
|
||||
links,
|
||||
prompt,
|
||||
systemPrompt,
|
||||
useAgent
|
||||
useAgent,
|
||||
extractId,
|
||||
}: {
|
||||
singleAnswerDocs: Document[];
|
||||
rSchema: any;
|
||||
@ -22,6 +23,7 @@ export async function singleAnswerCompletion({
|
||||
prompt: string;
|
||||
systemPrompt: string;
|
||||
useAgent: boolean;
|
||||
extractId?: string;
|
||||
}): Promise<{
|
||||
extract: any;
|
||||
tokenUsage: TokenUsage;
|
||||
@ -51,6 +53,7 @@ export async function singleAnswerCompletion({
|
||||
extractOptions: generationOptions,
|
||||
urls: singleAnswerDocs.map(doc => doc.metadata.url || doc.metadata.sourceURL || ""),
|
||||
useAgent,
|
||||
extractId,
|
||||
});
|
||||
|
||||
const completion = {
|
||||
|
@ -430,7 +430,8 @@ export async function performExtraction(
|
||||
prompt: request.prompt ?? "",
|
||||
systemPrompt: request.systemPrompt ?? "",
|
||||
doc,
|
||||
useAgent: isAgentExtractModelValid(request.agent?.model)
|
||||
useAgent: isAgentExtractModelValid(request.agent?.model),
|
||||
extractId,
|
||||
}, logger);
|
||||
|
||||
// Race between timeout and completion
|
||||
@ -741,6 +742,7 @@ export async function performExtraction(
|
||||
prompt: request.prompt ?? "",
|
||||
systemPrompt: request.systemPrompt ?? "",
|
||||
useAgent: isAgentExtractModelValid(request.agent?.model),
|
||||
extractId,
|
||||
});
|
||||
costTracking.smartScrapeCost += singleAnswerSmartScrapeCost;
|
||||
costTracking.smartScrapeCallCount += singleAnswerSmartScrapeCallCount;
|
||||
|
@ -184,10 +184,12 @@ export async function extractData({
|
||||
extractOptions,
|
||||
urls,
|
||||
useAgent,
|
||||
extractId,
|
||||
}: {
|
||||
extractOptions: GenerateCompletionsOptions;
|
||||
urls: string[];
|
||||
useAgent: boolean;
|
||||
extractId?: string;
|
||||
}): Promise<{
|
||||
extractedDataArray: any[];
|
||||
warning: any;
|
||||
@ -273,7 +275,7 @@ export async function extractData({
|
||||
let smartscrapeResults: SmartScrapeResult[];
|
||||
if (isSingleUrl) {
|
||||
smartscrapeResults = [
|
||||
await smartScrape(urls[0], extract?.smartscrape_prompt),
|
||||
await smartScrape(urls[0], extract?.smartscrape_prompt, extractId),
|
||||
];
|
||||
smartScrapeCost += smartscrapeResults[0].tokenUsage;
|
||||
smartScrapeCallCount++;
|
||||
@ -285,6 +287,7 @@ export async function extractData({
|
||||
return await smartScrape(
|
||||
urls[page.page_index],
|
||||
page.smartscrape_prompt,
|
||||
extractId,
|
||||
);
|
||||
}),
|
||||
);
|
||||
|
@ -49,6 +49,7 @@ export async function smartScrape(
|
||||
url: string,
|
||||
prompt: string,
|
||||
sessionId?: string,
|
||||
extractId?: string,
|
||||
): Promise<SmartScrapeResult> {
|
||||
try {
|
||||
logger.info("Initiating smart scrape request", { url, prompt, sessionId });
|
||||
|
Loading…
x
Reference in New Issue
Block a user