fix: 修复claude SSE捕获usage问题

This commit is contained in:
shaw
2025-10-12 23:05:48 +08:00
parent 6f6c274877
commit a67c34bee1
9 changed files with 43 additions and 42 deletions

View File

@@ -487,9 +487,12 @@ class ClaudeConsoleRelayService {
// 解析SSE数据寻找usage信息
for (const line of lines) {
if (line.startsWith('data: ') && line.length > 6) {
if (line.startsWith('data:')) {
const jsonStr = line.slice(5).trimStart()
if (!jsonStr || jsonStr === '[DONE]') {
continue
}
try {
const jsonStr = line.slice(6)
const data = JSON.parse(jsonStr)
// 收集usage数据