mirror of
https://git.mirrors.martin98.com/https://github.com/mendableai/firecrawl
synced 2025-08-13 01:09:04 +08:00
fix
This commit is contained in:
parent
2193bee133
commit
2245650bc3
@ -8,14 +8,15 @@ import {
|
|||||||
buildAnalyzeSchemaPrompt,
|
buildAnalyzeSchemaPrompt,
|
||||||
buildAnalyzeSchemaUserPrompt,
|
buildAnalyzeSchemaUserPrompt,
|
||||||
} from "../build-prompts";
|
} from "../build-prompts";
|
||||||
import { logger } from "../../../lib/logger";
|
|
||||||
import { jsonSchema } from "ai";
|
import { jsonSchema } from "ai";
|
||||||
import { getModel } from "../../../lib/generic-ai";
|
import { getModel } from "../../../lib/generic-ai";
|
||||||
|
import { Logger } from "winston";
|
||||||
|
|
||||||
export async function analyzeSchemaAndPrompt(
|
export async function analyzeSchemaAndPrompt(
|
||||||
urls: string[],
|
urls: string[],
|
||||||
schema: any,
|
schema: any,
|
||||||
prompt: string,
|
prompt: string,
|
||||||
|
logger: Logger,
|
||||||
): Promise<{
|
): Promise<{
|
||||||
isMultiEntity: boolean;
|
isMultiEntity: boolean;
|
||||||
multiEntityKeys: string[];
|
multiEntityKeys: string[];
|
||||||
@ -26,7 +27,7 @@ export async function analyzeSchemaAndPrompt(
|
|||||||
}> {
|
}> {
|
||||||
let cost = 0;
|
let cost = 0;
|
||||||
if (!schema) {
|
if (!schema) {
|
||||||
const genRes = await generateSchemaFromPrompt(prompt);
|
const genRes = await generateSchemaFromPrompt(prompt, logger);
|
||||||
schema = genRes.extract;
|
schema = genRes.extract;
|
||||||
cost = genRes.cost;
|
cost = genRes.cost;
|
||||||
}
|
}
|
||||||
|
@ -178,7 +178,7 @@ export async function performExtraction(
|
|||||||
|
|
||||||
let reqSchema = request.schema;
|
let reqSchema = request.schema;
|
||||||
if (!reqSchema && request.prompt) {
|
if (!reqSchema && request.prompt) {
|
||||||
const schemaGenRes = await generateSchemaFromPrompt(request.prompt);
|
const schemaGenRes = await generateSchemaFromPrompt(request.prompt, logger);
|
||||||
reqSchema = schemaGenRes.extract;
|
reqSchema = schemaGenRes.extract;
|
||||||
costTracking.otherCallCount++;
|
costTracking.otherCallCount++;
|
||||||
costTracking.otherCost += schemaGenRes.cost;
|
costTracking.otherCost += schemaGenRes.cost;
|
||||||
@ -214,7 +214,7 @@ export async function performExtraction(
|
|||||||
keyIndicators,
|
keyIndicators,
|
||||||
tokenUsage: schemaAnalysisTokenUsage,
|
tokenUsage: schemaAnalysisTokenUsage,
|
||||||
cost: schemaAnalysisCost,
|
cost: schemaAnalysisCost,
|
||||||
} = await analyzeSchemaAndPrompt(urls, reqSchema, request.prompt ?? "");
|
} = await analyzeSchemaAndPrompt(urls, reqSchema, request.prompt ?? "", logger);
|
||||||
|
|
||||||
logger.debug("Analyzed schema.", {
|
logger.debug("Analyzed schema.", {
|
||||||
isMultiEntity,
|
isMultiEntity,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user