mirror of
https://github.com/CJackHwang/ds2api.git
synced 2026-05-23 10:57:44 +08:00
feat: support explicit prompt token tracking in SSE parsing and stream handlers
This commit is contained in:
@@ -19,6 +19,20 @@ func TestParseDeepSeekSSELineDone(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestExtractTokenUsage(t *testing.T) {
|
||||
chunk := map[string]any{
|
||||
"p": "response/token_usage",
|
||||
"v": map[string]any{
|
||||
"prompt_tokens": 123,
|
||||
"completion_tokens": 456,
|
||||
},
|
||||
}
|
||||
p, c := extractAccumulatedTokenUsage(chunk)
|
||||
if p != 123 || c != 456 {
|
||||
t.Fatalf("expected 123/456, got %d/%d", p, c)
|
||||
}
|
||||
}
|
||||
|
||||
func TestParseSSEChunkForContentSimple(t *testing.T) {
|
||||
parts, finished, _ := ParseSSEChunkForContent(map[string]any{"v": "hello"}, false, "text")
|
||||
if finished {
|
||||
|
||||
Reference in New Issue
Block a user