refactor: Enhance deduplication logic and logging in wiki ingestion service
- Updated the `WikiDeduplicationPrompt` to clarify the criteria for identifying exact duplicates, emphasizing strict matching of real-world entities and concepts. - Improved the `appendLogEntry` method to include a summary parameter for better context in log entries, enhancing traceability of operations. - Consolidated log entry creation for both retraction and ingestion operations, ensuring chronological clarity in the log. - Implemented validation for slug merges to prevent mismatches based on entity types, improving the accuracy of deduplication. These changes enhance the clarity and reliability of the wiki ingestion process, leading to more accurate content management.
This commit is contained in:
@@ -306,15 +306,15 @@ func (s *wikiIngestService) ProcessWikiIngest(ctx context.Context, t *asynq.Task
|
||||
|
||||
totalPagesAffected = len(allPagesAffected)
|
||||
|
||||
// Append log entry for retracts (since retracts aren't in docResults)
|
||||
// Append log entries — one per operation for chronological traceability
|
||||
for _, op := range pendingOps {
|
||||
if op.Op == WikiOpRetract {
|
||||
s.appendLogEntry(ctx, WikiIngestPayload{
|
||||
TenantID: payload.TenantID,
|
||||
KnowledgeBaseID: payload.KnowledgeBaseID,
|
||||
}, "retract", op.KnowledgeID, op.DocTitle, op.PageSlugs, "")
|
||||
s.appendLogEntry(ctx, payload.KnowledgeBaseID, "retract", op.KnowledgeID, op.DocTitle, op.DocSummary, op.PageSlugs)
|
||||
}
|
||||
}
|
||||
for _, r := range docResults {
|
||||
s.appendLogEntry(ctx, payload.KnowledgeBaseID, "ingest", r.KnowledgeID, r.DocTitle, r.Summary, r.Pages)
|
||||
}
|
||||
|
||||
// Build change description for the Index Intro LLM prompt
|
||||
var changeDesc strings.Builder
|
||||
@@ -340,11 +340,6 @@ func (s *wikiIngestService) ProcessWikiIngest(ctx context.Context, t *asynq.Task
|
||||
}
|
||||
}
|
||||
|
||||
// Append log entry for ingests
|
||||
if len(docResults) > 0 {
|
||||
s.appendLogEntry(ctx, payload, "ingest", "", fmt.Sprintf("%d documents", len(docResults)), ingestPagesAffected, "")
|
||||
}
|
||||
|
||||
if len(retractPagesAffected) > 0 {
|
||||
logger.Infof(ctx, "wiki ingest: cleaning dead links")
|
||||
s.cleanDeadLinks(ctx, payload.KnowledgeBaseID)
|
||||
@@ -532,6 +527,7 @@ func (s *wikiIngestService) mapOneDocument(
|
||||
KnowledgeID: knowledgeID,
|
||||
DocTitle: docTitle,
|
||||
Summary: docSummaryLine,
|
||||
Pages: extractedPages,
|
||||
}, updates, nil
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user