feat: Introduce wiki_flag_issue tool for reporting wiki page issues
- Added a new tool, `wiki_flag_issue`, enabling users to report factual errors, mixed entities, or outdated information on wiki pages. - Updated the agent system prompt and tool definitions to include the new tool, enhancing the agent's capabilities for maintaining wiki accuracy. - Implemented backend functionality for creating, listing, and updating the status of flagged issues, ensuring effective tracking and resolution. These changes significantly improve the agent's ability to manage and report issues within the wiki, fostering a more reliable knowledge base.
This commit is contained in:
@@ -292,3 +292,29 @@ func (r *wikiPageRepository) CountOrphans(ctx context.Context, kbID string) (int
|
||||
}
|
||||
return count, nil
|
||||
}
|
||||
|
||||
func (r *wikiPageRepository) CreateIssue(ctx context.Context, issue *types.WikiPageIssue) error {
|
||||
return r.db.WithContext(ctx).Create(issue).Error
|
||||
}
|
||||
|
||||
func (r *wikiPageRepository) ListIssues(ctx context.Context, kbID string, slug string, status string) ([]*types.WikiPageIssue, error) {
|
||||
query := r.db.WithContext(ctx).Where("knowledge_base_id = ?", kbID)
|
||||
if slug != "" {
|
||||
query = query.Where("slug = ?", slug)
|
||||
}
|
||||
if status != "" {
|
||||
query = query.Where("status = ?", status)
|
||||
}
|
||||
|
||||
var issues []*types.WikiPageIssue
|
||||
if err := query.Order("created_at DESC").Find(&issues).Error; err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return issues, nil
|
||||
}
|
||||
|
||||
func (r *wikiPageRepository) UpdateIssueStatus(ctx context.Context, issueID string, status string) error {
|
||||
return r.db.WithContext(ctx).Model(&types.WikiPageIssue{}).
|
||||
Where("id = ?", issueID).
|
||||
Update("status", status).Error
|
||||
}
|
||||
|
||||
@@ -382,6 +382,7 @@ func (s *agentService) registerTools(
|
||||
tools.ToolWikiReadPage,
|
||||
tools.ToolWikiSearch,
|
||||
tools.ToolWikiReadSourceDoc,
|
||||
tools.ToolWikiFlagIssue,
|
||||
)
|
||||
logger.Infof(ctx, "Wiki KBs detected (%d), wiki tools added", len(wikiKBIDs))
|
||||
}
|
||||
@@ -453,6 +454,8 @@ func (s *agentService) registerTools(
|
||||
toolToRegister = tools.NewWikiSearchTool(s.wikiPageService, wikiKBIDs)
|
||||
case tools.ToolWikiReadSourceDoc:
|
||||
toolToRegister = tools.NewWikiReadSourceDocTool(s.knowledgeService, s.chunkService)
|
||||
case tools.ToolWikiFlagIssue:
|
||||
toolToRegister = tools.NewWikiFlagIssueTool(s.wikiPageService, wikiKBIDs)
|
||||
|
||||
default:
|
||||
logger.Warnf(ctx, "Unknown tool: %s", toolName)
|
||||
|
||||
@@ -477,3 +477,24 @@ func removeString(slice []string, s string) types.StringArray {
|
||||
}
|
||||
return result
|
||||
}
|
||||
|
||||
// CreateIssue logs a new issue for a wiki page
|
||||
func (s *wikiPageService) CreateIssue(ctx context.Context, issue *types.WikiPageIssue) (*types.WikiPageIssue, error) {
|
||||
if issue.ID == "" {
|
||||
issue.ID = uuid.New().String()
|
||||
}
|
||||
if err := s.repo.CreateIssue(ctx, issue); err != nil {
|
||||
return nil, fmt.Errorf("create wiki page issue: %w", err)
|
||||
}
|
||||
return issue, nil
|
||||
}
|
||||
|
||||
// ListIssues retrieves issues for a knowledge base
|
||||
func (s *wikiPageService) ListIssues(ctx context.Context, kbID string, slug string, status string) ([]*types.WikiPageIssue, error) {
|
||||
return s.repo.ListIssues(ctx, kbID, slug, status)
|
||||
}
|
||||
|
||||
// UpdateIssueStatus updates an issue's status
|
||||
func (s *wikiPageService) UpdateIssueStatus(ctx context.Context, issueID string, status string) error {
|
||||
return s.repo.UpdateIssueStatus(ctx, issueID, status)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user