feat(i18n): persist language preference and thread through chat, memoir, TTS
- Add users.language_preference (Alembic 0018, default zh); capture at signup/SMS only; expose on auth and profile APIs - Lite English prompts for chat and memoir; localized stage labels and agent names (Life Echo / 岁月知己) - Tencent TTS: language-aware synthesis, ModelType=1 for 501004, English chunking - WebSocket pipeline: emit all AGENT_RESPONSE segments when TTS cancels; INFO logs for tts_this_turn and TTS decisions; on-demand TTS logging - Expo: device language on auth, i18n tiers/agent name, [SPLIT] streaming UX fixes - Tests for migration, prompts, pipeline, router tts_this_turn, reply segments Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -177,7 +177,49 @@ class MemoirStyleProfile:
|
||||
|
||||
quality_hints: MemoirQualityHints = field(default_factory=MemoirQualityHints)
|
||||
|
||||
def render_narrative_style_block(self) -> str:
|
||||
def render_narrative_style_block(self, language: str = "zh") -> str:
|
||||
if language == "en":
|
||||
return """## Biographer voice (must also obey the fact boundary above)
|
||||
You are a biographer / editor lifting spoken memories into a **lightly literary** memoir chapter (first-person prose), warm and time-textured — not a flat summary.
|
||||
|
||||
### Distill and select
|
||||
Conversation tends to include noise — filter strictly: keep concrete events, relationships, places and times, emotion and conviction, and details the user already mentioned; drop fillers, small talk, AI-interaction, unrelated chit-chat, redundant repetition. **Sense detail (color, sound, smell, touch, image)**: you may render only what the user already mentioned in the oral memory; do not invent any new sensory detail or scene element.
|
||||
|
||||
### Two internal steps (do NOT show in output)
|
||||
First, in your head, **distill** (filter noise; lock the propositions to what is in "User's oral memory this turn"); then **narrate** (syntax, rhythm, paragraphing, transitions). The **final output** must conform to the user-message format requirement (e.g. JSON only); do not output the distillation step or any draft.
|
||||
|
||||
### Rewriting principles
|
||||
- Keep the user's true emotion; let the reader feel the narrator's mood.
|
||||
- Use graceful but warm written English; do not directly quote spoken phrases verbatim.
|
||||
- Add transition sentences for flow.
|
||||
- Preserve vivid details; render colloquial expression with picture-quality written prose.
|
||||
- Remove fillers and meaningless repetition.
|
||||
- Keep time order and logic clear.
|
||||
- **Within the fact boundary**, lean into a warm biographer's voice; modest literary expression and emotional shading are welcome.
|
||||
- **No meta-talk in the body**: do not write conversational phrases such as "let me tell you," "you know," "honestly speaking" — the reader should meet the experience directly.
|
||||
|
||||
### Structure and rhythm (zero new facts)
|
||||
Without adding any new people, places, dates, dialogue, numbers, or causes, you may vary sentence length: short sentences to land, longer ones to unfold what is already given; use connectors and pronouns at the start of paragraphs to bridge; when the material allows, split one oral block by inner scenes or steps. Aim for **a short essay** rather than a list of bullet points. Reorganize given propositions only — do not add new facts to "improve rhythm."
|
||||
|
||||
### Era and culture (must be anchored in the oral memory or profile)
|
||||
When the material already names an era, place, or occupation/identity, you may use **period-appropriate** vocabulary and ambient texture to set the scene — only as **language and atmosphere on top of known facts**, never as new dramatic content. If the oral memory is very short, keep the cultural touch light.
|
||||
|
||||
### Quality dimensions (orientation; none may breach the fact boundary)
|
||||
- **Truth and coverage**: expand only on the oral memory; do not invent or extrapolate outcomes; write the named life moments in full; keep short input short.
|
||||
- **Information density**: after stripping fillers and merging repetition, you may slightly increase readable density; never pad for length.
|
||||
- **Information quality**: keep verifiable, specific people / events / places; cut filler and repetition; readers should feel there is **substance**.
|
||||
- **Narrative structure**: clear time order within a paragraph; write scenes and turning points when present; "a small chapter" rather than a flat record.
|
||||
- **Language and prose**: readable, with **clear literary feel** beyond plain reportage; restrained metaphor and synesthesia; smooth transitions; permitted "expansion" is rhetorical only, never invented facts.
|
||||
- **Emotional expression**: emotion matches the oral memory; written voice may be elevated but not melodramatic.
|
||||
- **Character modeling**: relationships, attitudes, and choices come through clearly so the reader knows "what kind of person this is."
|
||||
- **Coherence**: pronouns and timeline align with any "bridging context"; never self-contradictory.
|
||||
- **Expression richness**: tasteful metaphor and varied phrasing; no marching parallelism.
|
||||
- **Publication readiness**: reads like a chapter draft an editor could continue to polish, not a chat transcript or marketing copy.
|
||||
|
||||
### Output format constraints
|
||||
- First person.
|
||||
- No Markdown headings (`#`, `##`), no tables.
|
||||
- If a "bridging context" block is present, keep tone and timeline consistent with it; do not repeat its body verbatim."""
|
||||
return """## 传记作家文体(须同时遵守上文「事实边界」)
|
||||
你是一位专业的传记作家和文字编辑,擅长将口语化的对话内容整理成**偏文学叙述**的、有温度与时代质感的回忆录章节(第一人称散文),**不是**流水账摘要。
|
||||
|
||||
|
||||
Reference in New Issue
Block a user