feat(agent): Minor tweaks
This commit is contained in:
parent
db6003ac5e
commit
e707bc630f
2 changed files with 29 additions and 1 deletions
|
|
@ -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 <answer> XML block
|
||||
- If you are a thinking or reasoning AI, do not use <answer> and </answer> or <links> and </links> 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
|
||||
|
||||
<examples>
|
||||
<example>
|
||||
<input>
|
||||
<question>
|
||||
What are the best ways to run Windows games on macOS with Apple Silicon? Get results from at least 3 sources.
|
||||
</question>
|
||||
<supervisor>
|
||||
What are the top methods for running Windows games on macOS with Apple Silicon, and what are three reliable sources that detail these methods?
|
||||
</supervisor>
|
||||
</input>
|
||||
<output>
|
||||
<answer>
|
||||
Run Windows games on macOS with Apple Silicon
|
||||
</answer>
|
||||
</output>
|
||||
</example>
|
||||
<example>
|
||||
<input>
|
||||
<question>
|
||||
What were the highlights of the race?
|
||||
</question>
|
||||
<supervisor>
|
||||
Find the highlights of the F1 Monaco Grand Prix.
|
||||
</supervisor>
|
||||
</input>
|
||||
<output>
|
||||
<answer>
|
||||
|
|
|
|||
|
|
@ -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 <answer> XML tag
|
||||
- If you need more information, provide a detailed question in a <question> XML tag
|
||||
- If you need more information, provide a detailed one line reason why the content is not sufficient in a <reason> 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:
|
||||
<answer>need_more_info</answer>
|
||||
<question>A question that would help gather more specific information to answer the query?</question>
|
||||
<reason>A one line reason why the content is not sufficient</reason>
|
||||
|
||||
# Context
|
||||
<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<url>' + doc.metada
|
|||
|
||||
const result = await workflow.invoke(initialState, {
|
||||
configurable: { thread_id: `agent_search_${Date.now()}` },
|
||||
recursionLimit: 15,
|
||||
recursionLimit: 20,
|
||||
});
|
||||
|
||||
return result;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue