feat: Implement wiki editing functionalities and UI components
- Added new tools for wiki page editing, including writing, replacing text, renaming, and deleting pages, with corresponding data structures for each action. - Enhanced the frontend with a new `WikiEditResult` component to display results of wiki edits, supporting multiple languages for improved accessibility. - Updated localization files for English and Chinese to include new strings related to wiki actions. - Modified existing tools to return structured data for wiki actions, improving the clarity and usability of the output messages. These changes significantly enhance the wiki editing capabilities, providing users with a more robust and user-friendly experience when managing wiki content.
This commit is contained in:
@@ -5,6 +5,7 @@ import (
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"fmt"
|
||||
"strings"
|
||||
|
||||
"github.com/Tencent/WeKnora/internal/application/repository"
|
||||
"github.com/Tencent/WeKnora/internal/types"
|
||||
@@ -142,8 +143,24 @@ func (t *wikiWritePageTool) Execute(ctx context.Context, args json.RawMessage) (
|
||||
// Rebuild the index page to reflect the new/updated summary
|
||||
_ = t.wikiPageService.RebuildIndexPage(ctx, kbID)
|
||||
|
||||
output := fmt.Sprintf("Successfully %s page [[%s]].\n- Title: %s\n- Type: %s\n- Summary: %s\n- Content length: %d chars", action, params.Slug, params.Title, params.PageType, params.Summary, len(params.Content))
|
||||
if len(params.Aliases) > 0 {
|
||||
output += fmt.Sprintf("\n- Aliases: %s", strings.Join(params.Aliases, ", "))
|
||||
}
|
||||
if len(resolvedRefs) > 0 {
|
||||
output += fmt.Sprintf("\n- Source refs: %d document(s)", len(resolvedRefs))
|
||||
}
|
||||
|
||||
return &types.ToolResult{
|
||||
Success: true,
|
||||
Output: fmt.Sprintf("Successfully %s page %s.", action, params.Slug),
|
||||
Output: output,
|
||||
Data: map[string]interface{}{
|
||||
"display_type": "wiki_write_page",
|
||||
"action": action,
|
||||
"slug": params.Slug,
|
||||
"title": params.Title,
|
||||
"page_type": params.PageType,
|
||||
"summary": params.Summary,
|
||||
},
|
||||
}, nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user