|
|
@@ -87,14 +87,23 @@ const isTypingActive = ref(false)
|
|
|
const lastContent = ref('') // 记录上一次的 content
|
|
|
const batchRevealTerminalTags = new Set(["PRE", "CODE", "TABLE", "THEAD", "TBODY", "TFOOT", "TR", "TH", "TD"])
|
|
|
const batchRevealListTags = new Set(["UL", "OL"])
|
|
|
+// 打字机速度。
|
|
|
+//
|
|
|
+// 基准参考主流 AI 的实测输出速度(字符口径):Claude 3.5 约 60 字符/秒、
|
|
|
+// DeepSeek-R1 约 75 字符/秒,主流区间 50~120,快速模型取的 120。
|
|
|
+//
|
|
|
+// 这里取区间**上沿**(4 字/33ms ≈ 121 字符/秒),原因:主流产品是模型边生成边流出,
|
|
|
+// 用户感知的等待约等于生成时间;而本项目的后端**一次返回整段**,打字机是纯额外延迟——
|
|
|
+// 同样 60 字符/秒会比主流慢一整段。取上沿让展开速度不再是瓶颈。
|
|
|
const typingInterval = 33
|
|
|
-const typingCharsPerTick = 2
|
|
|
+const typingCharsPerTick = 4
|
|
|
+// 积压越多打得越快,避免长回答的展开明显落后于阅读
|
|
|
const typingBurstThresholds = [
|
|
|
- { pendingLength: 32, batchSize: 4 },
|
|
|
- { pendingLength: 96, batchSize: 6 },
|
|
|
- { pendingLength: 256, batchSize: 8 },
|
|
|
- { pendingLength: 512, batchSize: 10 },
|
|
|
- { pendingLength: 1024, batchSize: 12 },
|
|
|
+ { pendingLength: 32, batchSize: 8 },
|
|
|
+ { pendingLength: 96, batchSize: 12 },
|
|
|
+ { pendingLength: 256, batchSize: 16 },
|
|
|
+ { pendingLength: 512, batchSize: 20 },
|
|
|
+ { pendingLength: 1024, batchSize: 24 },
|
|
|
]
|
|
|
const pendingCompactThreshold = 1000
|
|
|
let lastTypewriterTickTime = 0
|