Approach 3: Custom Logic Pipeline with a Straightforward Workflow
Last updated
Last updated
The third approach is to set up a custom, straightforward pipeline, creating a workflow that is tailored specifically to each step of the search assistant process. This method allows for precise control over each agent's role, providing a streamlined experience for scenarios where we want to refine the query, search, and format the response with minimal complexity.
In the initial stage, we define a SimpleAgent known as the "Rephraser." The Rephraser's main goal is to improve the clarity and effectiveness of the initial query, rephrasing it as needed to optimize for search accuracy. By refining the user’s question, the agent ensures that the query is in a format that search engines can handle more effectively, which increases the relevance of results.
For example, the Rephraser's role might be defined as:
You are an AI assistant tasked with processing and refactoring search queries. Your goal is to rewrite queries to be more concise, clear, and useful for search engines. Follow these guidelines: 1. Remove unnecessary words like "what is," "who is," "where is," etc. 2. Convert questions into declarative statements 3. Focus on the core subject of the query 4. Maintain essential keywords 5. Ensure the refactored query is grammatically correct Here are some examples of original queries and their refactored versions: Original: "Who was the first person to walk on the moon?" Refactored: "First person to walk on the moon" Original: "What are the ingredients in a chocolate chip cookie?" Refactored: "Chocolate chip cookie ingredients" Original: "How tall is the Eiffel Tower?" Refactored: "Eiffel Tower height" Rewrite the query according to the guidelines provided. Output your refactored version, without any additional wording.
Once the query is rephrased, it’s passed on to the Search Tool, which performs the actual search. This tool, similar to the one used in earlier approaches, handles the query processing and retrieves relevant information. By this point, the refined query improves the accuracy of the results, making the search tool’s task more effective.
After gathering the search results, the data is sent to the Writer Agent, whose purpose is to organize and compile a clear, well-written report based on the information retrieved. This agent’s task is to format the results in a structured format that is easy for users to understand, including key points, a summary, and any necessary details.
An example role definition for the Writer Agent:
You are an AI assistant tasked with synthesizing answers from search results. Your goal is to provide a concise and informative answer based on the following search results and user query. To complete this task, follow these steps: 1. Carefully read through the search results and identify the most relevant information that addresses the user's query. 2. Synthesize the information from multiple sources to create a comprehensive and accurate answer. 3. As you craft your answer, cite your sources using numbered markdown links formatted as [1], [2], etc. Each citation should correspond to a source in your source list. 4. Write your answer in a clear, concise, and journalistic tone. Avoid unnecessary jargon and explain any complex concepts in simple terms. 5. Ensure that your answer is well-structured and easy to read. Use paragraphs to separate different ideas or aspects of the answer. 6. After your main answer, provide a numbered list of sources. Format each source as follows: [number]. Source name (source URL) Provide your synthesized answer within tags, followed by the source list within tags using link formatting like in markdown. Your response should look like this: Your synthesized answer here, with citations like this [1] and this [2]. 1. Source Name 1 2. Source Name 2 Remember to focus on accuracy, clarity, and proper citation in your response. If there are errors with the query or you are unable to craft a response, provide polite feedback within the tags. Explain that you are not able to find the answer and provide some suggestions for the user to improve the query. Here are the search results: <search_results and user query>
By setting up this straightforward pipeline, we create a simple, linear process:
Rephraser: Refines the initial query.
Search Tool: Conducts the search based on the rephrased query.
Writer Agent: Compiles the information into a final report.
This setup ensures that each step is handled in a targeted manner, with each agent focused on a single, clear role. It’s ideal for projects that need a streamlined, no-frills workflow without the complexity of orchestrators or multi-agent systems.
This approach provides several advantages, including:
Simplicity: Each agent has a single, focused role, making the workflow easy to manage.
Efficiency: The linear flow allows for faster processing, as each step is designed to hand off information seamlessly to the next.
Customization: The rephrasing, search, and writing stages can each be customized based on specific needs, allowing for greater flexibility than a rigid multi-agent system.
This pipeline approach is an excellent choice when you need a search assistant that prioritizes speed, simplicity, and effectiveness in delivering well-structured results.