feat: kaikki fallback + definition code cleanup#138
Conversation
Flow is now: disk cache → LLM (GPT-5.2) → kaikki native → kaikki English. Covers ~60% of Dutch and ~52% of Romanian words where LLM has low confidence.
…nary URLs to kaikki results
|
Caution Review failedPull request was closed or merged during review 📝 WalkthroughWalkthroughThis change introduces a 3-tier definition lookup system (disk cache → LLM → offline Kaikki data) that unifies Kaikki lookup handling with native and English variants, replacing the previous 2-tier flow. Comprehensive unit tests validate fallback behavior, caching, and negative caching scenarios. Changes
Sequence DiagramsequenceDiagram
participant Caller as fetch_definition()
participant Cache as Disk Cache
participant LLM as LLM (GPT-5.2)
participant Kaikki as Kaikki Offline Data
Caller->>Cache: Check disk cache
alt Cache hit
Cache-->>Caller: Return cached definition
else Cache miss
Caller->>LLM: Request definition
alt LLM returns data
LLM-->>Caller: Definition with def_native, def_en
Caller->>Cache: Store positive cache
Cache-->>Caller: Cached result
else LLM returns None
Caller->>Kaikki: Fallback lookup_kaikki_native()
alt Native Kaikki found
Kaikki-->>Caller: Native definition
Caller->>Cache: Store positive cache
else Native Kaikki not found
Caller->>Kaikki: Fallback lookup_kaikki_english()
alt English Kaikki found
Kaikki-->>Caller: English definition
Caller->>Cache: Store positive cache
else All fallbacks failed
Caller->>Cache: Store negative cache
end
end
end
end
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches
🧪 Generate unit tests (beta)
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 |
Summary
Follow-up to #137. Adds kaikki (offline Wiktionary data) as a fallback tier when GPT-5.2 returns no definition, and cleans up code quality.
Changes
lookup_kaikki_native/lookup_kaikki_englishinto shared_lookup_kaikki()strip_html()andimport re(deprecated parser has its own copy)None)Definition flow
Test plan
@coderabbitai full review
Summary by CodeRabbit
New Features
Bug Fixes