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:
wizardchen
2026-04-21 19:19:57 +08:00
parent 4022f134bd
commit 37a517612d
9 changed files with 688 additions and 328 deletions
+1 -1
View File
@@ -35,7 +35,7 @@ If neither query nor range is provided, it returns the beginning of the document
},
"query": {
"type": "string",
"description": "Optional: A regex query to filter the document chunks. Use this to find specific quotes or details efficiently."
"description": "Optional: A regex query to filter the document chunks. Use this to find specific quotes or details efficiently. Remember to double-escape backslashes for JSON: write \"C\\\\+\\\\+\" (NOT \"C\\+\\+\") and \"\\\\d+\" (NOT \"\\d+\")."
},
"start_chunk_index": {
"type": "integer",