fix: clamp FOCUS_CHECK_MAX_TOKENS for Zhipu GLM compatibility - #823
Open
evan188199-tech wants to merge 19 commits into
Open
fix: clamp FOCUS_CHECK_MAX_TOKENS for Zhipu GLM compatibility#823evan188199-tech wants to merge 19 commits into
evan188199-tech wants to merge 19 commits into
Conversation
added 19 commits
August 10, 2026 19:33
- CharacterNode/CharacterEdge/CharacterGraph models with aliases, confidence,
evidence chapter IDs, and content-hash caching
- character_graph.py: LLM extraction (en/zh), scope-aware text collection
(current chapter or through-current, never future), Mermaid graph LR rendering
- Storage persistence at character_graphs/{scope}_{chapter_id}.json
- POST /api/v1/book/books/character-graph endpoint
- CharacterGraphPanel side panel with scope toggle + Mermaid diagram
- 15 unit tests (Mermaid escaping, truncation, safe IDs, model roundtrip)
Add POST /api/v1/immersive-reading/documents/{id}/character-graph endpoint
that extracts character relationships from EPUB chapters using the LLM and
renders them as Mermaid. Includes content-hash caching and scope support
(current chapter vs all chapters so far).
Frontend: add Characters button to the immersive reading toolbar and a
side panel with Mermaid diagram, character list, scope toggle, and refresh.
…nd quiz - Install react-reader@2.0.15 + epubjs@0.3.93 for native EPUB rendering - Add KidsEpubReader component with large child-friendly controls - Web Speech API TTS with sentence-by-sentence narration (0.85 rate) - Tap-to-translate: select any text to see Chinese translation - 3-question quiz per story (comprehension, sight word, sequence) - Backend: experience_mode field, kids-quiz endpoint, kids-progress endpoint - No Focus-Check gate in kids mode; progress tracked via EPUB CFI - Quiz cached by content hash; force refresh available - Existing Bob Books document works without re-uploading
- Tap sentence to read aloud (no text selection needed) - Double-tap to translate (no accidental popups) - Colorful gradient toolbar with large 48px buttons - Quiz: emoji labels instead of teacher jargon - Quiz: star rating + encouragement toast on submit - Bigger font (160%) and warmer background (#faf9f6) - Hint bar shows current interaction mode - Full-screen quiz overlay with rounded card design
- KidsProfile, KidsBookAssignment, KidsLearningProgress models - KidsManager service with profile CRUD, book assignment, per-profile progress - Parent management API (/api/v1/kids-admin) with auth - Child device-session API (/api/v1/kids) without adult auth - Quiz grading moved to backend, answer_index stripped from child responses - Standalone /kids page: profile picker, bookshelf, EPUB reader - Parent management panel in immersive-reading page - /kids route exempted from auth gate in proxy policy
- 120+ word dictionary covering Dolch sight words, Bob Books vocabulary, animals, food, nature, and common objects - Frequency-based word selection: words appearing more often in the chapter are prioritized for quiz questions - LLM prompt updated to focus on word-meaning questions instead of mixed types - When LLM fails or times out, deterministic fallback generates questions instantly from the built-in dictionary - Questions ask 'What does X mean?' with 4 simple English definitions - Fallback results cached so grading works on submit
- Three vocabulary tiers: 60 basic words (3-5), 120 early reader words (6-8), 130+ chapter book words (9-12) - 9-12 tier includes abstract concepts, emotions, descriptive language (venture, valiant, ancient, despair, wisdom, etc.) - Quiz difficulty follows the child profile age_band - LLM prompt also adapts: 9-12 gets nuanced definitions instead of childish ones - Deterministic fallback prefers harder words for 9-12 readers
- KidsProfile now stores birth_date (ISO date string) - age and age_band are computed properties that update automatically as the child grows older - Parent enters birth date in a date picker instead of choosing a band - Quiz difficulty, vocabulary tier, and LLM prompt all derive from the computed age - API responses include both birth_date, computed age, and age_band - Existing profiles without birth_date default to age 7 (6-8 band)
- /kids/manage page for creating profiles, entering birth dates, assigning books, and viewing child stats — no need to open a book first - 'Kids Reading' nav entry with Baby icon in the sidebar - Create form uses date picker for birth date with auto-age display - Fully self-contained, no dependency on immersive-reading page
- Backend: add device_url to profile responses (kids_admin + kids bootstrap) - Backend: POST /api/v1/kids/exit-verify endpoint (PIN check before exit) - Frontend: new /kids/p/[profileId] page — direct child entry with device memory - Frontend: PIN exit interception on shelf back button (/kids + /kids/p) - Frontend: PIN exit interception on reader 'Books' button - Frontend: /kids/manage shows per-child device link with copy button - Frontend: /kids auto-redirects to stored profile on return visits - Frontend: kids-api.ts adds exitVerify + device_url type
255_000 exceeded Zhipu GLM's max_tokens limit of [1,131072], causing code 1210 errors on Focus-Check calls.
- proxy-policy: exempt /kids/* EXCEPT /kids/manage (parent page needs auth) - add test verifying /kids/manage is NOT auth-exempt - fixes 'Failed to create profile' caused by 401 on admin API calls
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fix
FOCUS_CHECK_MAX_TOKENSwas set to255_000, which exceeds Zhipu GLM'smax_tokenslimit of[1, 131072], causingcode 1210errors on Focus-Check calls in immersive reading.Change
Focus-Check returns a small JSON payload (
passed/score/feedback/strengths/missing_points), so 4000 tokens is more than sufficient and safe across all providers.Testing
All 15 immersive_reading tests pass.