Repository navigation
feat(extractor): add inline 24h Redis LLM cache for keywords, questions, and summary - #18716
Conversation
|
Caution Review failedThe pull request is closed. ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (2)
📝 WalkthroughWalkthroughThe 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. ChangesExtraction cache
Estimated code review effort: 3 (Moderate) | ~20 minutes Suggested reviewers: 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
Poem
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. Comment |
cf44686 to
780bf1e
Compare
780bf1e to
db39c9d
Compare
db39c9d to
855afea
Compare
📌 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
metadataandtaggerextractions without adding heavy abstraction layers or touching other modules.🚀 Changes
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 viacallText(ctx, db, in, systemPrompt, chunkText), cleans the output, and writes back to Redis for 24 hours.runAutoKeywords,runAutoQuestions,runAutoSummarynow usecallTextCached.extractor_test.go):TestExtractor_LLMCacheKey(testing key determinism, task/model isolation, and NUL delimiter collision prevention).TestExtractor_CallTextCached_NoRedis_FailOpen(testing graceful fallback when Redis is absent).🧪 Verification
./build.sh --test ./internal/ingestion/component-> 100% PASS