根因:后端扣费用的是 fallback_amount=200(最低消费),用户剩14个token 时 14<200 导致扣费失败,但原有逻辑只在 remaining<=0 时才终止会话和 通知前端,remaining=14>0 时扣费失败被静默忽略。 修复: - 后端 voice_chat_router.py:扣费失败时(charge 返回 success=false) 始终终止事件循环并发送 error 事件,不再只判断 remaining<=0 - 后端 chat_router.py:文字聊天扣费失败时也发送 error 事件通知前端 - 前端 chatStore.js:token_update 消息带 warning 字段时(扣费失败), 标记 _realtimeTokenExhausted=true,断开 WebSocket,阻止继续使用 Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> |
||
|---|---|---|
| .. | ||
| api | ||
| config | ||
| migrations | ||
| models | ||
| scripts | ||
| services | ||
| utils | ||
| __init__.py | ||
| main.py | ||
| nohup.out | ||
| pet_data.db | ||
| requirements.txt | ||
| run.py | ||
| start.sh | ||
| test_token_charge.py | ||
| test_voice_conversation.py | ||