diff --git a/src/tools/query-rewriter.ts b/src/tools/query-rewriter.ts index ad991a9..16468a7 100644 --- a/src/tools/query-rewriter.ts +++ b/src/tools/query-rewriter.ts @@ -39,65 +39,65 @@ const model = genAI.getGenerativeModel({ function getPrompt(action: SearchAction): string { return `You are an expert Information Retrieval Assistant. Transform user queries into precise keyword combinations with strategic reasoning and appropriate search operators. -Core Rules: + 1. Generate search queries that directly include appropriate operators -2. Keep base keywords minimal: 2-4 words preferred +2. Keep base keywords minimal: 2-3 words preferred 3. Use exact match quotes for specific phrases that must stay together -4. Apply + operator for critical terms that must appear -5. Use - operator to exclude irrelevant or ambiguous terms -6. Add appropriate filters (filetype:, site:, lang:, loc:) when context suggests -7. Split queries only when necessary for distinctly different aspects -8. Preserve crucial qualifiers while removing fluff words -9. Make the query resistant to SEO manipulation +4. Split queries only when necessary for distinctly different aspects +5. Preserve crucial qualifiers while removing fluff words +6. Make the query resistant to SEO manipulation +7. When necessary, append to the query when context suggests + + + +A query can't only have operators; +Operators can't be at the start a query; -Available Operators: - "phrase" : exact match for phrases -- +term : must include term -- -term : exclude term +- +term : must include term; for critical terms that must appear +- -term : exclude term; exclude irrelevant or ambiguous terms - filetype:pdf/doc : specific file type - site:example.com : limit to specific site - lang:xx : language filter (ISO 639-1 code) - loc:xx : location filter (ISO 3166-1 code) - intitle:term : term must be in title - inbody:term : term must be in body text + -Examples with Strategic Reasoning: + + Input Query: What's the difference between ReactJS and Vue.js for building web applications? Thought: This is a comparison query. User is likely looking for technical evaluation and objective feature comparisons, possibly for framework selection decisions. We'll split this into separate queries to capture both high-level differences and specific technical aspects. Queries: [ - "react vue comparison +advantages +disadvantages", - "react vue performance +benchmark" + "react performance", + "vue performance", + "react vue comparison", ] Input Query: How to fix a leaking kitchen faucet? Thought: This is a how-to query seeking practical solutions. User likely wants step-by-step guidance and visual demonstrations for DIY repair. We'll target both video tutorials and written guides. Queries: [ - "kitchen faucet leak repair site:youtube.com", - "faucet drip fix +diy +steps -professional", - "faucet repair tools +parts +guide" + "kitchen faucet leak repair", + "faucet drip fix site:youtube.com", + "how to repair faucet " ] Input Query: What are healthy breakfast options for type 2 diabetes? Thought: This is a health-specific informational query. User needs authoritative medical advice combined with practical meal suggestions. Splitting into medical guidelines and recipes will provide comprehensive coverage. Queries: [ - "type 2 diabetes breakfast guidelines site:edu", - "diabetic breakfast recipes -sugar +easy" + "what to eat for type 2 diabetes", + "type 2 diabetes breakfast guidelines", + "diabetic breakfast recipes" ] Input Query: Latest AWS Lambda features for serverless applications Thought: This is a product research query focused on recent updates. User wants current information about specific technology features, likely for implementation purposes. We'll target official docs and community insights. Queries: [ - "aws lambda features site:aws.amazon.com intitle:2024", - "lambda serverless best practices +new -legacy" -] - -Input Query: Find Python tutorials on YouTube, but exclude beginner content -Thought: This is an educational resource query with specific skill-level requirements. User is seeking advanced learning materials on a specific platform. We'll focus on advanced topics while explicitly filtering out basic content. -Queries: [ - "python advanced programming site:youtube.com -beginner -basics", - "python design patterns tutorial site:youtube.com" + "aws lambda features site:aws.amazon.com intitle:2025", + "new features lambda serverless" ] + Now, process this query: Input Query: ${action.searchQuery}