Enhance Search Intent Classification in Prompts

- Updated the search intent classification prompt for the Need Search agent to provide clearer instructions and rules for classifying user queries.
- Revised the output format to specify JSON structure requirements, ensuring consistency in responses.
- Expanded classification rules to include additional categories and examples, improving the agent's ability to accurately determine the need for external searches.
- Enhanced clarity in the prompt content to facilitate better understanding and implementation by users.
This commit is contained in:
Max 2025-12-17 17:35:44 +08:00
parent 9e4febf782
commit ac0fa681ea
3 changed files with 190 additions and 171 deletions

View file

@ -103,12 +103,19 @@ func (r *Executor) RunDirect() (*Report, error) {
output := extractOutput(response)
r.output.DirectOutput(output)
// Determine connector: user-specified > agent default
connector := r.opts.Connector
if connector == "" {
connector = agentInfo.Connector
}
// Return minimal report (for exit code handling)
return &Report{
Summary: &Summary{
Total: 1,
Passed: 1,
AgentID: agentInfo.ID,
Total: 1,
Passed: 1,
AgentID: agentInfo.ID,
Connector: connector,
},
}, nil
}
@ -165,13 +172,19 @@ func (r *Executor) RunTests() (*Report, error) {
return nil, fmt.Errorf("failed to get assistant: %w", err)
}
// Determine connector: user-specified > agent default
connector := r.opts.Connector
if connector == "" {
connector = agentInfo.Connector
}
// Create report
report := &Report{
Summary: &Summary{
Total: len(testCases),
AgentID: agentInfo.ID,
AgentPath: agentInfo.Path,
Connector: r.opts.Connector,
Connector: connector,
RunsPerCase: r.opts.Runs,
},
Environment: NewEnvironment(r.opts.UserID, r.opts.TeamID),

File diff suppressed because it is too large Load diff

View file

@ -1,20 +1,26 @@
# Need Search Agent
- role: system
content: |
Classify if user query needs external search.
You are a search intent classifier. Analyze user input and classify whether external search is needed.
## Rules
NO SEARCH: greetings, chitchat, math, code generation, text processing, general knowledge
WEB: real-time data (weather, news, prices), current events, recent info
KB: documentation, how-to, configuration, FAQ
DB: user data, orders, records, business data
## Your Task
- Classify the user's query into search categories
- Output MUST be a JSON with exactly these 3 fields: need_search, search_types, confidence
- DO NOT extract keywords, DO NOT answer the question, DO NOT add explanations
## Response (JSON only)
{"need_search": bool, "search_types": ["web"|"kb"|"db"], "confidence": 0-1}
## Classification Rules
need_search=false: greetings, chitchat, math, code requests, text processing, general knowledge, philosophy
need_search=true with search_types=["web"]: weather, news, prices, exchange rates, live events, real-time info
need_search=true with search_types=["kb"]: docs, how-to, config, FAQ, product info, policies
need_search=true with search_types=["db"]: user data (my orders, my balance), account info, business records
## Required Output Format (JSON only, no markdown)
{"need_search": true/false, "search_types": [], "confidence": 0.0-1.0}
## Examples
"Hello" → {"need_search": false, "search_types": [], "confidence": 0.99}
"Today's weather" → {"need_search": true, "search_types": ["web"], "confidence": 0.95}
"Write a sort function" → {"need_search": false, "search_types": [], "confidence": 0.90}
"Write a bubble sort in JS" → {"need_search": false, "search_types": [], "confidence": 0.95}
"用JavaScript写冒泡排序" → {"need_search": false, "search_types": [], "confidence": 0.95}
"How to config DB" → {"need_search": true, "search_types": ["kb"], "confidence": 0.85}
"My orders" → {"need_search": true, "search_types": ["db"], "confidence": 0.95}