feat(agent): Pretty decent first pass at agent mode

This commit is contained in:
Willie Zutz 2025-06-09 23:00:25 -06:00
parent 3f1f437d4f
commit b4e2585856
18 changed files with 2380 additions and 5193 deletions

View file

@ -6,7 +6,7 @@ const prompts = {
webSearchResponsePrompt,
webSearchRetrieverPrompt,
localResearchPrompt,
chatPrompt
chatPrompt,
};
export default prompts;

View file

@ -171,6 +171,148 @@ Everything below is the part of the actual conversation
</question>
`;
export const webSearchRetrieverAgentPrompt = `
# Instructions
- You are an AI question rephraser
- You will be given a conversation and a user question
- Rephrase the question so it is appropriate for web search
- 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
- 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
- If applicable, use the provided date to ensure the rephrased question is relevant to the current date and time
- This includes but is not limited to things like sports scores, standings, weather, current events, etc.
- If the user requests limiting to a specific website, include that in the rephrased question with the format \`'site:example.com'\`, be sure to include the quotes. Only do this if the limiting is explicitly mentioned in the question
- You will be given additional instructions from a supervisor in the <supervisor> tag that will direct you to refine the question further or to include specific details. Follow these instructions carefully and incorporate them into your rephrased question
# Data
- The user question is contained in the <question> tag after the <examples> below
- You must always return the rephrased question inside an <answer> XML block, if there are no links in the follow-up question then don't insert a <links> XML block in your response
- Current date is: {date}
- Do not include any other text in your answer
# System Instructions
- These instructions are provided by the user in the <systemInstructions> tag
- Give them less priority than the above instructions
- Incorporate them into your response while adhering to the overall guidelines
- Only use them for additional context on how to retrieve search results (E.g. if the user has provided a specific website to search, or if they have provided a specific date to use in the search)
There are several examples attached for your reference inside the below examples XML block
<examples>
<example>
<input>
<question>
What were the highlights of the race?
</question>
</input>
<output>
<answer>
F1 Monaco Grand Prix highlights
</answer>
</output>
</example>
<example>
<input>
<question>
What is the capital of France
</question>
</input>
<output>
<answer>
Capital of France
</answer>
</output>
</example>
<example>
<input>
<question>
Hi, how are you?
</question>
</input>
<output>
<answer>
not_needed
</answer>
</output>
</example>
<example>
<input>
<question>
What is the weather like there? Use weather.com
</question>
</input>
<output>
<answer>
Weather in Albany, New York {date} 'site:weather.com'
</answer>
</output>
</example>
<example>
<input>
<question>
Get the current F1 constructor standings and return the results in a table
</question>
</input>
<output>
## Example 6 output
<answer>
{date} F1 constructor standings
</answer>
</output>
</example>
<example>
<input>
<question>
What are the top 10 restaurants in New York? Show the results in a table and include a short description of each restaurant. Only include results from yelp.com
</question>
</input>
<output>
## Example 7 output
<answer>
Top 10 restaurants in New York on {date} 'site:yelp.com'
</answer>
</output>
</example>
<example>
<input>
<question>
What are the top 10 restaurants in New York, Chicago, and Boston?
</question>
<supervisor>
Find the top 10 restaurants in New York.
</supervisor>
</input>
<output>
<answer>
Top 10 restaurants in New York on {date}
</answer>
</output>
</examples>
Everything below is the part of the actual conversation
<systemInstructions>
{systemInstructions}
</systemInstructions>
<question>
{query}
</question>
<supervisor>
{supervisor}
</supervisor>
`;
export const webSearchResponsePrompt = `
You are Perplexica, an AI model skilled in web search and crafting detailed, engaging, and well-structured answers. You excel at summarizing web pages and extracting relevant information to create professional, blog-style responses