mirror of
https://github.com/dzhng/deep-research.git
synced 2026-03-22 07:57:16 +08:00
added concurrency limit env var
This commit is contained in:
@@ -1,6 +1,7 @@
|
|||||||
FIRECRAWL_KEY="YOUR_KEY"
|
FIRECRAWL_KEY="YOUR_KEY"
|
||||||
# If you want to use your self-hosted Firecrawl, add the following below:
|
# If you want to use your self-hosted Firecrawl, add the following below:
|
||||||
# FIRECRAWL_BASE_URL="http://localhost:3002"
|
# FIRECRAWL_BASE_URL="http://localhost:3002"
|
||||||
|
# FIRECRAWL_CONCURRENCY="2"
|
||||||
|
|
||||||
OPENAI_KEY="YOUR_KEY"
|
OPENAI_KEY="YOUR_KEY"
|
||||||
CONTEXT_SIZE="128000"
|
CONTEXT_SIZE="128000"
|
||||||
|
|||||||
@@ -152,9 +152,9 @@ The final report will be saved as `report.md` or `answer.md` in your working dir
|
|||||||
|
|
||||||
### Concurrency
|
### Concurrency
|
||||||
|
|
||||||
If you have a paid version of Firecrawl or a local version, feel free to increase the `ConcurrencyLimit` in `deep-research.ts` so it runs a lot faster.
|
If you have a paid version of Firecrawl or a local version, feel free to increase the `ConcurrencyLimit` by setting the `CONCURRENCY_LIMIT` environment variable so it runs faster.
|
||||||
|
|
||||||
If you have a free version, you may sometimes run into rate limit errors, you can reduce the limit (but it will run a lot slower).
|
If you have a free version, you may sometimes run into rate limit errors, you can reduce the limit to 1 (but it will run a lot slower).
|
||||||
|
|
||||||
### DeepSeek R1
|
### DeepSeek R1
|
||||||
|
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ type ResearchResult = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
// increase this if you have higher API rate limits
|
// increase this if you have higher API rate limits
|
||||||
const ConcurrencyLimit = 2;
|
const ConcurrencyLimit = Number(process.env.FIRECRAWL_CONCURRENCY) || 2;
|
||||||
|
|
||||||
// Initialize Firecrawl with optional API key and optional base url
|
// Initialize Firecrawl with optional API key and optional base url
|
||||||
|
|
||||||
@@ -89,8 +89,8 @@ async function processSerpResult({
|
|||||||
numLearnings?: number;
|
numLearnings?: number;
|
||||||
numFollowUpQuestions?: number;
|
numFollowUpQuestions?: number;
|
||||||
}) {
|
}) {
|
||||||
const contents = compact(result.data.map(item => item.markdown)).map(
|
const contents = compact(result.data.map(item => item.markdown)).map(content =>
|
||||||
content => trimPrompt(content, 25_000),
|
trimPrompt(content, 25_000),
|
||||||
);
|
);
|
||||||
log(`Ran ${query}, found ${contents.length} contents`);
|
log(`Ran ${query}, found ${contents.length} contents`);
|
||||||
|
|
||||||
@@ -104,9 +104,7 @@ async function processSerpResult({
|
|||||||
.join('\n')}</contents>`,
|
.join('\n')}</contents>`,
|
||||||
),
|
),
|
||||||
schema: z.object({
|
schema: z.object({
|
||||||
learnings: z
|
learnings: z.array(z.string()).describe(`List of learnings, max of ${numLearnings}`),
|
||||||
.array(z.string())
|
|
||||||
.describe(`List of learnings, max of ${numLearnings}`),
|
|
||||||
followUpQuestions: z
|
followUpQuestions: z
|
||||||
.array(z.string())
|
.array(z.string())
|
||||||
.describe(
|
.describe(
|
||||||
@@ -139,9 +137,7 @@ export async function writeFinalReport({
|
|||||||
`Given the following prompt from the user, write a final report on the topic using the learnings from research. Make it as as detailed as possible, aim for 3 or more pages, include ALL the learnings from research:\n\n<prompt>${prompt}</prompt>\n\nHere are all the learnings from previous research:\n\n<learnings>\n${learningsString}\n</learnings>`,
|
`Given the following prompt from the user, write a final report on the topic using the learnings from research. Make it as as detailed as possible, aim for 3 or more pages, include ALL the learnings from research:\n\n<prompt>${prompt}</prompt>\n\nHere are all the learnings from previous research:\n\n<learnings>\n${learningsString}\n</learnings>`,
|
||||||
),
|
),
|
||||||
schema: z.object({
|
schema: z.object({
|
||||||
reportMarkdown: z
|
reportMarkdown: z.string().describe('Final report on the topic in Markdown'),
|
||||||
.string()
|
|
||||||
.describe('Final report on the topic in Markdown'),
|
|
||||||
}),
|
}),
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -170,9 +166,7 @@ export async function writeFinalAnswer({
|
|||||||
schema: z.object({
|
schema: z.object({
|
||||||
exactAnswer: z
|
exactAnswer: z
|
||||||
.string()
|
.string()
|
||||||
.describe(
|
.describe('The final answer, make it short and concise, just the answer, no other text'),
|
||||||
'The final answer, make it short and concise, just the answer, no other text',
|
|
||||||
),
|
|
||||||
}),
|
}),
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -245,9 +239,7 @@ export async function deepResearch({
|
|||||||
const allUrls = [...visitedUrls, ...newUrls];
|
const allUrls = [...visitedUrls, ...newUrls];
|
||||||
|
|
||||||
if (newDepth > 0) {
|
if (newDepth > 0) {
|
||||||
log(
|
log(`Researching deeper, breadth: ${newBreadth}, depth: ${newDepth}`);
|
||||||
`Researching deeper, breadth: ${newBreadth}, depth: ${newDepth}`,
|
|
||||||
);
|
|
||||||
|
|
||||||
reportProgress({
|
reportProgress({
|
||||||
currentDepth: newDepth,
|
currentDepth: newDepth,
|
||||||
|
|||||||
Reference in New Issue
Block a user