chore: first commit

This commit is contained in:
Han Xiao
2025-02-05 10:33:06 +08:00
parent 0dd06c1057
commit 94faae18a2

View File

@@ -39,65 +39,65 @@ const model = genAI.getGenerativeModel({
function getPrompt(action: SearchAction): string { 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. return `You are an expert Information Retrieval Assistant. Transform user queries into precise keyword combinations with strategic reasoning and appropriate search operators.
Core Rules: <rules>
1. Generate search queries that directly include appropriate operators 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 3. Use exact match quotes for specific phrases that must stay together
4. Apply + operator for critical terms that must appear 4. Split queries only when necessary for distinctly different aspects
5. Use - operator to exclude irrelevant or ambiguous terms 5. Preserve crucial qualifiers while removing fluff words
6. Add appropriate filters (filetype:, site:, lang:, loc:) when context suggests 6. Make the query resistant to SEO manipulation
7. Split queries only when necessary for distinctly different aspects 7. When necessary, append <query-operators> to the query when context suggests
8. Preserve crucial qualifiers while removing fluff words
9. Make the query resistant to SEO manipulation
<query-operators>
A query can't only have operators;
Operators can't be at the start a query;
Available Operators:
- "phrase" : exact match for phrases - "phrase" : exact match for phrases
- +term : must include term - +term : must include term; for critical terms that must appear
- -term : exclude term - -term : exclude term; exclude irrelevant or ambiguous terms
- filetype:pdf/doc : specific file type - filetype:pdf/doc : specific file type
- site:example.com : limit to specific site - site:example.com : limit to specific site
- lang:xx : language filter (ISO 639-1 code) - lang:xx : language filter (ISO 639-1 code)
- loc:xx : location filter (ISO 3166-1 code) - loc:xx : location filter (ISO 3166-1 code)
- intitle:term : term must be in title - intitle:term : term must be in title
- inbody:term : term must be in body text - inbody:term : term must be in body text
</query-operators>
Examples with Strategic Reasoning: </rules>
<examples>
Input Query: What's the difference between ReactJS and Vue.js for building web applications? 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. 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: [ Queries: [
"react vue comparison +advantages +disadvantages", "react performance",
"react vue performance +benchmark" "vue performance",
"react vue comparison",
] ]
Input Query: How to fix a leaking kitchen faucet? 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. 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: [ Queries: [
"kitchen faucet leak repair site:youtube.com", "kitchen faucet leak repair",
"faucet drip fix +diy +steps -professional", "faucet drip fix site:youtube.com",
"faucet repair tools +parts +guide" "how to repair faucet "
] ]
Input Query: What are healthy breakfast options for type 2 diabetes? 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. 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: [ Queries: [
"type 2 diabetes breakfast guidelines site:edu", "what to eat for type 2 diabetes",
"diabetic breakfast recipes -sugar +easy" "type 2 diabetes breakfast guidelines",
"diabetic breakfast recipes"
] ]
Input Query: Latest AWS Lambda features for serverless applications 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. 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: [ Queries: [
"aws lambda features site:aws.amazon.com intitle:2024", "aws lambda features site:aws.amazon.com intitle:2025",
"lambda serverless best practices +new -legacy" "new features lambda serverless"
]
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"
] ]
</examples>
Now, process this query: Now, process this query:
Input Query: ${action.searchQuery} Input Query: ${action.searchQuery}