Skip to content

Commit e1e6b40

Browse files
committed
chore: improve prompts
1 parent 5e3eb5f commit e1e6b40

File tree

2 files changed

+9
-6
lines changed

2 files changed

+9
-6
lines changed

lib/deep-research.ts

+7-5
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ export function generateSearchQueries({
112112
lp += ` Use ${searchLanguage} for the SERP queries.`
113113
}
114114
const prompt = [
115-
`Given the following prompt from the user, generate a list of SERP queries to research the topic. Return a maximum of ${numQueries} queries, but feel free to return less if the original prompt is clear. Make sure each query is unique and not similar to each other: <prompt>${query}</prompt>\n\n`,
115+
`Given the following prompt from the user, generate a list of highly effective Google search queries to research the topic. Return a maximum of ${numQueries} queries, but feel free to return less if the original prompt is clear. Make sure each query is creative, unique and not similar to each other: <prompt>${query}</prompt>`,
116116
learnings
117117
? `Here are some learnings from previous research, use them to generate more specific queries: ${learnings.join(
118118
'\n',
@@ -182,7 +182,7 @@ function processSearchResult({
182182
const jsonSchema = JSON.stringify(zodToJsonSchema(schema))
183183
const contents = results.map((item) => trimPrompt(item.content))
184184
const prompt = [
185-
`Given the following contents from a SERP search for the query <query>${query}</query>, extract key learnings from the contents. For each learning, include the source URL. Return a maximum of ${numLearnings} learnings, but feel free to return less if the contents are clear. Make sure each learning is unique and not similar to each other. The learnings should be as detailed and information dense as possible. Include any entities like people, places, companies, products, things, etc in the learnings, as well as any exact metrics, numbers, or dates. Also generate up to ${numFollowUpQuestions} follow-up questions that could help explore this topic further.`,
185+
`Given the following contents from a SERP search for the query <query>${query}</query>, extract ${numLearnings} key learnings from the contents. Make sure each learning is unique and not similar to each other. The learnings should be as detailed and information dense as possible. Include any entities like people, places, companies, products, things, etc in the learnings, as well as any exact metrics, numbers, or dates. Also generate up to ${numFollowUpQuestions} follow-up questions that could help explore this topic further.`,
186186
`<contents>${contents
187187
.map(
188188
(content, index) =>
@@ -211,8 +211,10 @@ export function writeFinalReport({
211211
const learningsString = trimPrompt(
212212
learnings
213213
.map(
214-
(learning) =>
215-
`<learning url="${learning.url}">\n${learning.learning}\n</learning>`,
214+
(learning, index) =>
215+
`<learning index="${index + 1}">
216+
${learning.learning}
217+
</learning>`,
216218
)
217219
.join('\n'),
218220
)
@@ -221,7 +223,7 @@ export function writeFinalReport({
221223
`<prompt>${prompt}</prompt>`,
222224
`Here are all the learnings from previous research:`,
223225
`<learnings>\n${learningsString}\n</learnings>`,
224-
`Write the report using Markdown. When citing information, use numbered citations with superscript numbers in square brackets (e.g., [1], [2], [3]). Each citation should correspond to the index of the source in your learnings list. DO NOT include the actual URLs in the report text - only use the citation numbers.`,
226+
`Write the report using Markdown. Be factual, NEVER lie or make things up. Cite learnings from previous research when needed, using numbered citations like "[1]". Each citation should correspond to the index of the source in your learnings list. DO NOT include the actual URLs in the report text - only use the citation numbers.`,
225227
languagePrompt(language),
226228
`## Deep Research Report`,
227229
].join('\n\n')

lib/feedback.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,8 @@ export function generateFeedback({
2929
})
3030
const jsonSchema = JSON.stringify(zodToJsonSchema(schema))
3131
const prompt = [
32-
`Given the following query from the user, ask ${numQuestions} follow up questions to clarify the research direction. Return a maximum of ${numQuestions} questions, but feel free to return less if the original query is clear: <query>${query}</query>`,
32+
`Given the following query from the user, ask several follow up questions to clarify the research direction. Return a maximum of ${numQuestions} questions. Feel free to return less if the original query is clear, but always provide at least 1 question.`,
33+
`<query>${query}</query>`,
3334
`You MUST respond in JSON matching this JSON schema: ${jsonSchema}`,
3435
languagePrompt(language),
3536
].join('\n\n')

0 commit comments

Comments
 (0)