feat: Add web search results handling and enhance knowledge retrieval features

- Introduced a new endpoint to fetch chunks by ID, improving access to specific knowledge base entries.
- Updated tool result types to include web search results, enhancing the display capabilities in the chat component.
- Enhanced the AgentStreamDisplay component to support rendering web search results with improved HTML formatting.
- Implemented logic for managing web search result summaries and citations, ensuring a cohesive user experience.
- Refactored session management to accommodate new web search functionalities, improving overall system integration.
This commit is contained in:
wizardchen
2025-11-11 22:26:59 +08:00
parent d2adc38baf
commit 14d0e663cc
25 changed files with 1317 additions and 650 deletions
+11 -11
View File
@@ -767,17 +767,17 @@ func (t *KnowledgeSearchTool) formatOutput(
})
}
// Add usage guidance
output += "\n\n=== Usage Guidelines ===\n"
output += "- High relevance (>=0.8): directly usable for answering\n"
output += "- Medium relevance (0.6-0.8): use as supplementary reference\n"
output += "- Low relevance (<0.6): use with caution, may not be accurate\n"
if totalBeforeFilter > len(results) {
output += "- Results below threshold have been automatically filtered\n"
}
output += "- Full content is already included in search results above\n"
output += "- Results are deduplicated across knowledge bases and sorted by relevance\n"
output += "- Use get_related_chunks to expand context if needed\n"
// // Add usage guidance
// output += "\n\n=== Usage Guidelines ===\n"
// output += "- High relevance (>=0.8): directly usable for answering\n"
// output += "- Medium relevance (0.6-0.8): use as supplementary reference\n"
// output += "- Low relevance (<0.6): use with caution, may not be accurate\n"
// if totalBeforeFilter > len(results) {
// output += "- Results below threshold have been automatically filtered\n"
// }
// output += "- Full content is already included in search results above\n"
// output += "- Results are deduplicated across knowledge bases and sorted by relevance\n"
// output += "- Use get_related_chunks to expand context if needed\n"
data := map[string]interface{}{
"knowledge_base_ids": kbsToSearch,
+4 -9
View File
@@ -232,19 +232,14 @@ func (t *WebSearchTool) Execute(ctx context.Context, args map[string]interface{}
formattedResults = append(formattedResults, resultData)
}
output += "=== Usage Guidelines ===\n"
output += "- Use these results to answer questions about current information\n"
output += "- Verify information from multiple sources when possible\n"
output += "- Check the publication date to ensure information is current\n"
output += "- Results are automatically compressed to extract relevant content\n"
return &types.ToolResult{
Success: true,
Output: output,
Data: map[string]interface{}{
"query": query,
"results": formattedResults,
"count": len(webResults),
"query": query,
"results": formattedResults,
"count": len(webResults),
"display_type": "web_search_results",
},
}, nil
}