feat: Enhance agent retrieval strategies and regex handling
- Updated the agent system prompt to emphasize the use of regex for chunk searches, improving retrieval accuracy and efficiency. - Introduced a new `Capabilities` field in the `KnowledgeBaseInfo` struct to define the retrieval surfaces available for each knowledge base, guiding the agent's strategy selection. - Enhanced the `grep_chunks` tool to support regex queries, allowing for more flexible and powerful text pattern matching in knowledge base chunks. - Improved JSON handling in the `RepairJSON` function to address invalid escape sequences, particularly for regex patterns, ensuring robust parsing and error handling. - Updated documentation and comments across various files to clarify usage and expectations for regex and knowledge base capabilities. These changes significantly enhance the agent's ability to retrieve relevant information while ensuring the integrity of input data handling.
This commit is contained in:
@@ -78,7 +78,13 @@ type KnowledgeBaseInfo struct {
|
||||
Type string // Knowledge base type: "document" or "faq"
|
||||
Description string
|
||||
DocCount int
|
||||
RecentDocs []RecentDocInfo // Recently added documents (up to 10)
|
||||
// Capabilities lists the retrieval surfaces this KB exposes. Any subset of
|
||||
// {"wiki", "chunks"}. "chunks" is present when the KB has vector and/or
|
||||
// keyword (BM25) indexing enabled. This is the *deterministic* source of
|
||||
// truth the agent should consult before picking a retrieval strategy —
|
||||
// significantly more reliable than running probing searches.
|
||||
Capabilities []string
|
||||
RecentDocs []RecentDocInfo // Recently added documents (up to 10)
|
||||
}
|
||||
|
||||
// PlaceholderDefinition defines a placeholder exposed to UI/configuration
|
||||
@@ -118,8 +124,12 @@ func formatKnowledgeBaseList(kbInfos []*KnowledgeBaseInfo) string {
|
||||
if kbType == "" {
|
||||
kbType = "document"
|
||||
}
|
||||
b.WriteString(fmt.Sprintf("<knowledge_base id=\"%s\" name=\"%s\" type=\"%s\" doc_count=\"%d\">\n",
|
||||
kb.ID, kb.Name, kbType, kb.DocCount))
|
||||
capsAttr := ""
|
||||
if len(kb.Capabilities) > 0 {
|
||||
capsAttr = fmt.Sprintf(" capabilities=\"%s\"", strings.Join(kb.Capabilities, ","))
|
||||
}
|
||||
b.WriteString(fmt.Sprintf("<knowledge_base id=\"%s\" name=\"%s\" type=\"%s\" doc_count=\"%d\"%s>\n",
|
||||
kb.ID, kb.Name, kbType, kb.DocCount, capsAttr))
|
||||
if kb.Description != "" {
|
||||
b.WriteString(fmt.Sprintf("<description>%s</description>\n", kb.Description))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user