Skip to content

Commit

Permalink
improve prompts
Browse files Browse the repository at this point in the history
  • Loading branch information
PacoVK committed Feb 2, 2025
1 parent ebc673c commit a2dbf4c
Show file tree
Hide file tree
Showing 2 changed files with 55 additions and 42 deletions.
87 changes: 50 additions & 37 deletions src/agent/prompts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,66 +4,79 @@ export const queryWriterInstructions = (
The query will gather information related to a specific topic.
Topic:
<TOPIC>
${researchTopic}
</TOPIC>
Return your query as a JSON object:
<FORMAT>
Format your response as a JSON object with ALL three of these exact keys:
- "query": The actual search query string
- "aspect": The specific aspect of the topic being researched
- "rationale": Brief explanation of why this query is relevant
</FORMAT>
<EXAMPLE>
Example output:
{{
"query": "string",
"aspect": "string",
"rationale": "string"
"query": "machine learning transformer architecture explained",
"aspect": "technical architecture",
"rationale": "Understanding the fundamental structure of transformer models"
}}
`;
</EXAMPLE>
export const summarizerInstructions = `Your goal is to generate a high-quality summary of the web search results.
Provide your response in JSON format:`;

When EXTENDING an existing summary:
1. Seamlessly integrate new information without repeating what's already covered
2. Maintain consistency with the existing content's style and depth
3. Only add new, non-redundant information
4. Ensure smooth transitions between existing and new content
export const summarizerInstructions = `<GOAL>
Generate a high-quality summary of the web search results and keep it concise / related to the user topic.
</GOAL>
<REQUIREMENTS>
When creating a NEW summary:
1. Highlight the most relevant information from each source
2. Provide a concise overview of the key points related to the report topic
3. Emphasize significant findings or insights
4. Ensure a coherent flow of information
1. Highlight the most relevant information related to the user topic from the search results
2. Ensure a coherent flow of information
When EXTENDING an existing summary:
1. Read the existing summary and new search results carefully.
2. Compare the new information with the existing summary.
3. For each piece of new information:
a. If it's related to existing points, integrate it into the relevant paragraph.
b. If it's entirely new but relevant, add a new paragraph with a smooth transition.
c. If it's not relevant to the user topic, skip it.
4. Ensure all additions are relevant to the user's topic.
5. Verify that your final output differs from the input summary.
</REQUIREMENTS >
CRITICAL REQUIREMENTS:
- Start IMMEDIATELY with the summary content - no introductions or meta-commentary
- DO NOT include ANY of the following:
* Phrases about your thought process ("Let me start by...", "I should...", "I'll...")
* Explanations of what you're going to do
* Statements about understanding or analyzing the sources
* Mentions of summary extension or integration
- Focus ONLY on factual, objective information
- Maintain a consistent technical depth
- Avoid redundancy and repetition
- DO NOT use phrases like "based on the new results" or "according to additional sources"
- DO NOT add a References or Works Cited section
- DO NOT use any XML-style tags like <think> or <answer>
- Begin directly with the summary text without any tags, prefixes, or meta-commentary
<FORMATTING >
- Start directly with the updated summary, without preamble or titles. Do not use XML tags in the output.
</FORMATTING >
`;

export const reflectionInstructions = (
researchTopic: string,
) => `You are an expert research assistant analyzing a summary about ${researchTopic}.
Your tasks:
1. Identify knowledge gaps or areas that need deeper exploration
2. Generate a follow-up question that would help expand your understanding
3. Focus on technical details, implementation specifics, or emerging trends that weren't fully covered
<GOAL>
1. Identify knowledge gaps or areas that need deeper exploration
2. Generate a follow-up question that would help expand your understanding
3. Focus on technical details, implementation specifics, or emerging trends that weren't fully covered
</GOAL>
<REQUIREMENTS>
Ensure the follow-up question is self-contained and includes necessary context for web search.
</REQUIREMENTS>
Format your response as a JSON object with two fields:
- knowledgeGap: Describe what information is missing or needs clarification
- followUpQuery: Write a specific question to address this gap
<FORMAT>
Format your response as a JSON object with these exact keys:
- knowledgeGap: Describe what information is missing or needs clarification
- followUpQuery: Write a specific question to address this gap
</FORMAT>
<EXAMPLE>
Example output:
{{
"knowledgeGap": "The summary lacks information about performance metrics and benchmarks",
"followUpQuery": "What are typical performance benchmarks and metrics used to evaluate [specific technology]?"
}}
</EXAMPLE>
Provide your analysis in JSON format:`;
10 changes: 5 additions & 5 deletions src/nodes/summarizeSources.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@ export const summarizeSources = async (
let humanMessageContent;

if (existingSummary) {
humanMessageContent = `Extend the existing summary: ${existingSummary}\n\n
Include new search results: ${mostRecentWebResearch}
That addresses the following topic: ${state.researchTopic}`;
humanMessageContent = `<User Input> \n ${state.researchTopic} \n <User Input>\n\n
<Existing Summary> \n ${existingSummary} \n <Existing Summary>\n\n
<New Search Results> \n ${mostRecentWebResearch} \n <New Search Results>`;
} else {
humanMessageContent = `Generate a summary of these search results: ${mostRecentWebResearch}
That addresses the following topic: ${state.researchTopic}`;
humanMessageContent = `<User Input> \n ${state.researchTopic} \n <User Input>\n\n
<Search Results> \n ${mostRecentWebResearch} \n <Search Results>`;
}

const configuration = ensureConfiguration(config);
Expand Down

0 comments on commit a2dbf4c

Please sign in to comment.