mirror of
https://git.mirrors.martin98.com/https://github.com/mendableai/firecrawl
synced 2025-08-11 23:49:02 +08:00
Nick: let user format the analysis
This commit is contained in:
parent
7e7b7e10fe
commit
010c8750d4
@ -10,6 +10,7 @@ export const deepResearchRequestSchema = z.object({
|
|||||||
maxDepth: z.number().min(1).max(12).default(7).describe('Maximum depth of research iterations'),
|
maxDepth: z.number().min(1).max(12).default(7).describe('Maximum depth of research iterations'),
|
||||||
maxUrls: z.number().min(1).max(1000).default(20).describe('Maximum number of URLs to analyze'),
|
maxUrls: z.number().min(1).max(1000).default(20).describe('Maximum number of URLs to analyze'),
|
||||||
timeLimit: z.number().min(30).max(600).default(300).describe('Time limit in seconds'),
|
timeLimit: z.number().min(30).max(600).default(300).describe('Time limit in seconds'),
|
||||||
|
analysisPrompt: z.string().describe('The prompt to use for the final analysis').optional(),
|
||||||
// @deprecated Use query instead
|
// @deprecated Use query instead
|
||||||
topic: z.string().describe('The topic or question to research').optional(),
|
topic: z.string().describe('The topic or question to research').optional(),
|
||||||
}).refine(data => data.query || data.topic, {
|
}).refine(data => data.query || data.topic, {
|
||||||
|
@ -14,6 +14,7 @@ interface DeepResearchServiceOptions {
|
|||||||
maxDepth: number;
|
maxDepth: number;
|
||||||
maxUrls: number;
|
maxUrls: number;
|
||||||
timeLimit: number;
|
timeLimit: number;
|
||||||
|
analysisPrompt: string;
|
||||||
subId?: string;
|
subId?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -262,6 +263,7 @@ export async function performDeepResearch(options: DeepResearchServiceOptions) {
|
|||||||
options.query,
|
options.query,
|
||||||
state.getFindings(),
|
state.getFindings(),
|
||||||
state.getSummaries(),
|
state.getSummaries(),
|
||||||
|
options.analysisPrompt,
|
||||||
);
|
);
|
||||||
|
|
||||||
await state.addActivity({
|
await state.addActivity({
|
||||||
|
@ -253,6 +253,7 @@ export class ResearchLLMService {
|
|||||||
topic: string,
|
topic: string,
|
||||||
findings: DeepResearchFinding[],
|
findings: DeepResearchFinding[],
|
||||||
summaries: string[],
|
summaries: string[],
|
||||||
|
analysisPrompt: string,
|
||||||
): Promise<string> {
|
): Promise<string> {
|
||||||
const { extract } = await generateCompletions({
|
const { extract } = await generateCompletions({
|
||||||
logger: this.logger.child({
|
logger: this.logger.child({
|
||||||
@ -265,7 +266,9 @@ export class ResearchLLMService {
|
|||||||
"You are an expert research analyst who creates comprehensive, well-structured reports. Your reports are detailed, properly formatted in Markdown, and include clear sections with citations. Today's date is " +
|
"You are an expert research analyst who creates comprehensive, well-structured reports. Your reports are detailed, properly formatted in Markdown, and include clear sections with citations. Today's date is " +
|
||||||
new Date().toISOString().split("T")[0],
|
new Date().toISOString().split("T")[0],
|
||||||
prompt: trimToTokenLimit(
|
prompt: trimToTokenLimit(
|
||||||
`Create a comprehensive research report on "${topic}" based on the collected findings and analysis.
|
analysisPrompt
|
||||||
|
? `${analysisPrompt}\n\nResearch data:\n${findings.map((f) => `[From ${f.source}]: ${f.text}`).join("\n")}`
|
||||||
|
: `Create a comprehensive research report on "${topic}" based on the collected findings and analysis.
|
||||||
|
|
||||||
Research data:
|
Research data:
|
||||||
${findings.map((f) => `[From ${f.source}]: ${f.text}`).join("\n")}
|
${findings.map((f) => `[From ${f.source}]: ${f.text}`).join("\n")}
|
||||||
|
@ -412,6 +412,7 @@ const processDeepResearchJobInternal = async (
|
|||||||
timeLimit: job.data.request.timeLimit,
|
timeLimit: job.data.request.timeLimit,
|
||||||
subId: job.data.subId,
|
subId: job.data.subId,
|
||||||
maxUrls: job.data.request.maxUrls,
|
maxUrls: job.data.request.maxUrls,
|
||||||
|
analysisPrompt: job.data.request.analysisPrompt,
|
||||||
});
|
});
|
||||||
|
|
||||||
if(result.success) {
|
if(result.success) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user