diff --git a/src/lib/prompts/webSearch.ts b/src/lib/prompts/webSearch.ts index 53b580f..7ad604c 100644 --- a/src/lib/prompts/webSearch.ts +++ b/src/lib/prompts/webSearch.ts @@ -179,6 +179,7 @@ export const webSearchRetrieverAgentPrompt = ` - Only add additional information or change the meaning of the question if it is necessary for clarity or relevance to the conversation such as adding a date or time for current events, or using historical content to augment the question with relevant context - Do not make up any new information like links or URLs - Condense the question to its essence and remove any unnecessary details +- Search queries should be short and to the point, focusing on the main topic or question - Ensure the question is grammatically correct and free of spelling errors - If it is a simple writing task or a greeting (unless the greeting contains a question after it) like Hi, Hello, How are you, etc. instead of a question then you need to return \`not_needed\` as the response in the XML block - If you are a thinking or reasoning AI, do not use and or and tags in your thinking. Those tags should only be used in the final output @@ -202,11 +203,29 @@ export const webSearchRetrieverAgentPrompt = ` There are several examples attached for your reference inside the below examples XML block + + + + What are the best ways to run Windows games on macOS with Apple Silicon? Get results from at least 3 sources. + + + What are the top methods for running Windows games on macOS with Apple Silicon, and what are three reliable sources that detail these methods? + + + + + Run Windows games on macOS with Apple Silicon + + + What were the highlights of the race? + + Find the highlights of the F1 Monaco Grand Prix. + diff --git a/src/lib/search/agentSearch.ts b/src/lib/search/agentSearch.ts index 316fb6b..58b9871 100644 --- a/src/lib/search/agentSearch.ts +++ b/src/lib/search/agentSearch.ts @@ -208,6 +208,7 @@ export class AgentSearch { - The content should completely address the query, providing detailed explanations, relevant facts, and necessary context - Use the content provided in the \`context\` tag, as well as the historical context of the conversation, to make your determination - If the context provides conflicting information, explain the discrepancies and what additional information is needed to resolve them +- If the user is asking for a specific number of sources, ensure that we have enough sources to meet that requirement - Today's date is ${formatDateForLLM(new Date())} # Output Format @@ -223,6 +224,7 @@ export class AgentSearch { - Avoid giving the same guidance more than once, and avoid repeating the same question multiple times - Respond with your answer in a XML tag - If you need more information, provide a detailed question in a XML tag +- If you need more information, provide a detailed one line reason why the content is not sufficient in a XML tag # Refinement History - The following questions have been asked to refine the search @@ -238,6 +240,7 @@ ${state.searchInstructionHistory.map((question) => ` - ${question}`).join('\n') - If the content is not sufficient: need_more_info A question that would help gather more specific information to answer the query? +A one line reason why the content is not sufficient # Context @@ -262,15 +265,21 @@ ${state.searchInstructionHistory.map((question) => ` - ${question}`).join('\n') // Parse the response to extract the analysis result const analysisOutputParser = new LineOutputParser({ key: 'answer' }); const moreInfoOutputParser = new LineOutputParser({ key: 'question' }); + const reasonOutputParser = new LineOutputParser({ key: 'reason' }); + const analysisResult = await analysisOutputParser.parse( response.content as string, ); const moreInfoQuestion = await moreInfoOutputParser.parse( response.content as string, ); + const reason = await reasonOutputParser.parse( + response.content as string, + ); console.log('Analysis result:', analysisResult); console.log('More info question:', moreInfoQuestion); + console.log('Reason for insufficiency:', reason); if (analysisResult.startsWith('need_more_info')) { return new Command({ @@ -487,7 +496,7 @@ ${doc.metadata?.url.toLowerCase().includes('file') ? '' : '\n' + doc.metada const result = await workflow.invoke(initialState, { configurable: { thread_id: `agent_search_${Date.now()}` }, - recursionLimit: 15, + recursionLimit: 20, }); return result;