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) output := extractOutput(response)
r.output.DirectOutput(output) 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 minimal report (for exit code handling)
return &Report{ return &Report{
Summary: &Summary{ Summary: &Summary{
Total: 1, Total: 1,
Passed: 1, Passed: 1,
AgentID: agentInfo.ID, AgentID: agentInfo.ID,
Connector: connector,
}, },
}, nil }, nil
} }
@ -165,13 +172,19 @@ func (r *Executor) RunTests() (*Report, error) {
return nil, fmt.Errorf("failed to get assistant: %w", err) 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 // Create report
report := &Report{ report := &Report{
Summary: &Summary{ Summary: &Summary{
Total: len(testCases), Total: len(testCases),
AgentID: agentInfo.ID, AgentID: agentInfo.ID,
AgentPath: agentInfo.Path, AgentPath: agentInfo.Path,
Connector: r.opts.Connector, Connector: connector,
RunsPerCase: r.opts.Runs, RunsPerCase: r.opts.Runs,
}, },
Environment: NewEnvironment(r.opts.UserID, r.opts.TeamID), 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 # Need Search Agent
- role: system - role: system
content: | 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 ## Your Task
NO SEARCH: greetings, chitchat, math, code generation, text processing, general knowledge - Classify the user's query into search categories
WEB: real-time data (weather, news, prices), current events, recent info - Output MUST be a JSON with exactly these 3 fields: need_search, search_types, confidence
KB: documentation, how-to, configuration, FAQ - DO NOT extract keywords, DO NOT answer the question, DO NOT add explanations
DB: user data, orders, records, business data
## Response (JSON only) ## Classification Rules
{"need_search": bool, "search_types": ["web"|"kb"|"db"], "confidence": 0-1} 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 ## Examples
"Hello" → {"need_search": false, "search_types": [], "confidence": 0.99} "Hello" → {"need_search": false, "search_types": [], "confidence": 0.99}
"Today's weather" → {"need_search": true, "search_types": ["web"], "confidence": 0.95} "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} "How to config DB" → {"need_search": true, "search_types": ["kb"], "confidence": 0.85}
"My orders" → {"need_search": true, "search_types": ["db"], "confidence": 0.95} "My orders" → {"need_search": true, "search_types": ["db"], "confidence": 0.95}