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:
42
api/alembic/versions/0018_users_language_preference.py
Normal file
42
api/alembic/versions/0018_users_language_preference.py
Normal file
@@ -0,0 +1,42 @@
|
||||
"""users:language_preference 字段
|
||||
|
||||
Revision ID: 0018_users_language_preference
|
||||
Revises: 0017_segment_narrative_defer
|
||||
"""
|
||||
|
||||
from typing import Sequence, Union
|
||||
|
||||
import sqlalchemy as sa
|
||||
|
||||
from alembic import op
|
||||
|
||||
revision: str = "0018_users_language_preference"
|
||||
down_revision: Union[str, None] = "0017_segment_narrative_defer"
|
||||
branch_labels: Union[str, Sequence[str], None] = None
|
||||
depends_on: Union[str, Sequence[str], None] = None
|
||||
|
||||
|
||||
def _column_names(table_name: str) -> set[str]:
|
||||
bind = op.get_bind()
|
||||
inspector = sa.inspect(bind)
|
||||
return {column["name"] for column in inspector.get_columns(table_name)}
|
||||
|
||||
|
||||
def upgrade() -> None:
|
||||
columns = _column_names("users")
|
||||
if "language_preference" not in columns:
|
||||
op.add_column(
|
||||
"users",
|
||||
sa.Column(
|
||||
"language_preference",
|
||||
sa.String(length=8),
|
||||
nullable=False,
|
||||
server_default=sa.text("'zh'"),
|
||||
),
|
||||
)
|
||||
|
||||
|
||||
def downgrade() -> None:
|
||||
columns = _column_names("users")
|
||||
if "language_preference" in columns:
|
||||
op.drop_column("users", "language_preference")
|
||||
Reference in New Issue
Block a user