From 5e113ddba3c24e4495d312e38e46227ea16379b8 Mon Sep 17 00:00:00 2001 From: wizardchen Date: Tue, 7 Apr 2026 21:42:29 +0800 Subject: [PATCH] refactor: Remove detectSynthesisOpportunities function from wiki_ingest service - Eliminated the detectSynthesisOpportunities function, which was responsible for suggesting synthesis opportunities based on page counts and types. This function was deemed unnecessary as it relied on heuristic methods without LLM integration. - The removal streamlines the codebase and focuses on essential functionalities within the wiki_ingest service. This change simplifies the service and prepares it for future enhancements that may involve more sophisticated synthesis logic. --- internal/application/service/wiki_ingest.go | 43 --------------------- 1 file changed, 43 deletions(-) diff --git a/internal/application/service/wiki_ingest.go b/internal/application/service/wiki_ingest.go index 12068426..1fef6279 100644 --- a/internal/application/service/wiki_ingest.go +++ b/internal/application/service/wiki_ingest.go @@ -920,49 +920,6 @@ func (s *wikiIngestService) upsertExtractedPages( return affected, nil } -// detectSynthesisOpportunities checks if there are enough pages to suggest synthesis. -// Pure heuristic — no LLM call, just counts pages by type and returns suggestion strings. -func (s *wikiIngestService) detectSynthesisOpportunities(ctx context.Context, payload WikiIngestPayload) []string { - resp, err := s.wikiService.ListPages(ctx, &types.WikiPageListRequest{ - KnowledgeBaseID: payload.KnowledgeBaseID, - PageSize: 500, - SortBy: "page_type", - SortOrder: "asc", - }) - if err != nil { - return nil - } - - // Count pages by type, collect example titles - typeCounts := make(map[string]int) - typeExamples := make(map[string][]string) - for _, p := range resp.Pages { - if p.PageType == types.WikiPageTypeIndex || p.PageType == types.WikiPageTypeLog { - continue - } - typeCounts[p.PageType]++ - if len(typeExamples[p.PageType]) < 5 { - typeExamples[p.PageType] = append(typeExamples[p.PageType], p.Title) - } - } - - var suggestions []string - - if count := typeCounts[types.WikiPageTypeEntity]; count >= 3 { - examples := strings.Join(typeExamples[types.WikiPageTypeEntity], ", ") - suggestions = append(suggestions, - fmt.Sprintf("Synthesis opportunity: %d entity pages (e.g. %s) could be synthesized into a comparison or overview page", count, examples)) - } - - if count := typeCounts[types.WikiPageTypeConcept]; count >= 3 { - examples := strings.Join(typeExamples[types.WikiPageTypeConcept], ", ") - suggestions = append(suggestions, - fmt.Sprintf("Synthesis opportunity: %d concept pages (e.g. %s) could be synthesized into a thematic overview", count, examples)) - } - - return suggestions -} - // rebuildIndexPage regenerates the index page from all existing pages func (s *wikiIngestService) rebuildIndexPage(ctx context.Context, chatModel chat.Chat, payload WikiIngestPayload, lang string) error { // List all pages