feat: Enhance wiki tools and agent system prompt for improved knowledge retrieval

- Updated the agent system prompt to clarify the workflow for knowledge retrieval, emphasizing the use of `wiki_search` and `wiki_read_page` tools for specific queries and general overviews.
- Modified the `wikiReadPageTool` to support reading multiple wiki pages simultaneously, improving efficiency in fetching content.
- Enhanced the `wikiSearchTool` to utilize PostgreSQL POSIX regular expressions for more effective search queries, allowing for complex pattern matching.
- Adjusted the `wikiPageRepository` to replace `ILIKE` with regex matching for search queries, increasing the precision of search results.

These changes significantly improve the agent's ability to retrieve and synthesize information from the wiki, enhancing user interactions and response accuracy.
This commit is contained in:
wizardchen
2026-04-09 22:56:08 +08:00
parent ba552c9042
commit 76c13c9bfe
3 changed files with 177 additions and 87 deletions
+2 -4
View File
@@ -242,12 +242,10 @@ func (r *wikiPageRepository) Search(ctx context.Context, kbID string, query stri
limit = 50
}
likePattern := "%" + query + "%"
var pages []*types.WikiPage
if err := r.db.WithContext(ctx).
Where("knowledge_base_id = ? AND (title ILIKE ? OR content ILIKE ? OR summary ILIKE ? OR slug ILIKE ?)",
kbID, likePattern, likePattern, likePattern, likePattern).
Where("knowledge_base_id = ? AND (title ~* ? OR content ~* ? OR summary ~* ? OR slug ~* ?)",
kbID, query, query, query, query).
Where("status != ?", "archived").
Order("updated_at DESC").
Limit(limit).