Skip to content

feat(extractor): add inline 24h Redis LLM cache for keywords, questions, and summary - #18716

Merged
yuzhichang merged 1 commit into
infiniflow:mainfrom
jay77721:feat/extractor-llm-cache
Aug 25, 2026
Merged

yuzhichang merged 1 commit into
infiniflow:mainfrom
jay77721:feat/extractor-llm-cache

Conversation

@jay77721

@jay77721 jay77721 commented Aug 25, 2026 •

Copy link
Copy Markdown
Member

📌 Summary

This PR adds a minimal, direct 24-hour Redis LLM cache to the Extractor component for textual extractions (keywords, questions, summary).

Identical chunk extractions under the same task type, model, and system prompt now hit Redis directly within a 24-hour window, matching the behavior already present in metadata and tagger extractions without adding heavy abstraction layers or touching other modules.


🚀 Changes

  1. Inline Cache Helper (extractor.go):
    • extractorLLMCacheKey(taskType, modelID, systemPrompt, text) creates Redis keys using xxhash: kc:extractor:{taskType}:{hash}.
    • callTextCached: checks Redis for cached results; on cache miss, invokes LLM via callText(ctx, db, in, systemPrompt, chunkText), cleans the output, and writes back to Redis for 24 hours.
  2. Extractor Integration:
    • runAutoKeywords, runAutoQuestions, runAutoSummary now use callTextCached.
  3. Unit Tests (extractor_test.go):
    • Added TestExtractor_LLMCacheKey (testing key determinism, task/model isolation, and NUL delimiter collision prevention).
    • Added TestExtractor_CallTextCached_NoRedis_FailOpen (testing graceful fallback when Redis is absent).

🧪 Verification

  • ./build.sh --test ./internal/ingestion/component -> 100% PASS

@dosubot dosubot Bot added size:M This PR changes 30-99 lines, ignoring generated files. 💞 feature Feature request, pull request that fullfill a new feature. labels Aug 25, 2026
@coderabbitai

coderabbitai Bot commented Aug 25, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 9fc3d2af-5d4e-45a1-b445-b9eaf99d5ac8

📥 Commits

Reviewing files that changed from the base of the PR and between bfe0797 and 855afea.

📒 Files selected for processing (2)
  • internal/ingestion/component/extractor.go
  • internal/ingestion/component/extractor_test.go

📝 Walkthrough

Walkthrough

The extraction component adds a 24-hour Redis cache for keyword, question, and summary results. Cache keys include task, model, prompt, and chunk data. Cache failures fall back to live LLM calls.

Changes

Extraction cache

Layer / File(s) Summary
Cache key and result handling
internal/ingestion/component/extractor.go
Adds xxhash-based cache keys and best-effort Redis reads and writes for cleaned, valid LLM results.
Extraction path integration
internal/ingestion/component/extractor.go
Routes keyword, question, and summary extraction through callTextCached.
Cache key and fail-open validation
internal/ingestion/component/extractor_test.go
Tests key determinism, task and model isolation, collision prevention, and extraction without Redis.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Suggested reviewers: yuzhichang, euvre, jinhai-cn

Sequence Diagram(s)

sequenceDiagram
  participant Extractor
  participant Redis
  participant callText
  Extractor->>Redis: Read cache key
  Redis-->>Extractor: Cached result or cache miss
  Extractor->>callText: Request extraction on cache miss
  callText-->>Extractor: Return cleaned result
  Extractor->>Redis: Store result for 24 hours
Loading

Poem

A rabbit caches words today
Keywords and questions find their way
Summaries rest in Redis bright
Misses call the LLM right
Errors do not stay
Fresh results hop away


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@jay77721
jay77721 force-pushed the feat/extractor-llm-cache branch from cf44686 to 780bf1e Compare August 25, 2026 01:53
@jay77721 jay77721 changed the title feat(extractor): add 24h Redis LLM cache for keywords, questions, and summary feat(extractor): add inline 24h Redis LLM cache for keywords, questions, and summary Aug 25, 2026
@jay77721 jay77721 added the ci Continue Integration label Aug 25, 2026
@jay77721
jay77721 force-pushed the feat/extractor-llm-cache branch from 780bf1e to db39c9d Compare August 25, 2026 01:57
@jay77721
jay77721 force-pushed the feat/extractor-llm-cache branch from db39c9d to 855afea Compare August 25, 2026 01:59
@jay77721
jay77721 requested a review from yuzhichang August 25, 2026 01:59
@yuzhichang
yuzhichang merged commit 704eb07 into infiniflow:main Aug 25, 2026
3 checks passed
@jay77721
jay77721 deleted the feat/extractor-llm-cache branch September 2, 2026 02:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ci Continue Integration 💞 feature Feature request, pull request that fullfill a new feature. size:M This PR changes 30-99 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants