Files
life-echo/api/app/features/user/schemas.py
Kevin ccdc4e4277 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>
2026-05-11 16:16:49 +08:00

72 lines
1.8 KiB
Python

from typing import Literal, Optional
from pydantic import BaseModel, Field
LanguagePreference = Literal["zh", "en"]
class UserProfileResponse(BaseModel):
id: str
phone: str
email: Optional[str] = None
nickname: str
avatar_url: Optional[str] = None
subscription_type: str
created_at: str
birth_year: Optional[int] = None
birth_place: Optional[str] = None
grew_up_place: Optional[str] = None
occupation: Optional[str] = None
language_preference: LanguagePreference = "zh"
class UpdateUserProfileRequest(BaseModel):
birth_year: Optional[int] = None
birth_place: Optional[str] = None
grew_up_place: Optional[str] = None
occupation: Optional[str] = None
class TestSubscriptionRequest(BaseModel):
action: Literal["activate", "deactivate"]
plan_id: Optional[str] = "pro"
class TestSubscriptionResponse(BaseModel):
success: bool
message: str
subscription_type: str
class SubmitFeedbackRequest(BaseModel):
"""提交反馈请求"""
content: str = Field(..., min_length=1, max_length=2000, description="反馈内容")
contact: Optional[str] = Field(None, max_length=100, description="联系方式(可选)")
class FeedbackResponse(BaseModel):
"""反馈响应"""
id: str
message: str
# 与前端约定:请求体必须携带该固定口令,防止误触清空。
PURGE_USER_DATA_CONFIRMATION = "我确认永久删除我的全部回忆与对话数据"
class PurgeUserDataRequest(BaseModel):
"""清空账号下全部业务数据(保留登录账号与手机号等;并清空出生年/出生地等档案字段)。"""
confirmation: str = Field(
...,
min_length=1,
description=f"必须为「{PURGE_USER_DATA_CONFIRMATION}",
)
class PurgeUserDataResponse(BaseModel):
success: bool
message: str