feat: enhance content filtering, token usage tracking, and stream error handling in chat-stream modules

This commit is contained in:
CJACK
2026-04-05 13:41:38 +08:00
parent 47dc121690
commit eff979d9ef
13 changed files with 439 additions and 33 deletions

View File

@@ -0,0 +1,8 @@
{
"parts": [],
"finished": true,
"new_type": "text",
"content_filter": true,
"output_tokens": 77,
"error_message": ""
}

View File

@@ -0,0 +1,7 @@
{
"parts": [
{"text": "正常输出", "type": "text"}
],
"finished": false,
"new_type": "text"
}

View File

@@ -1,6 +1,8 @@
{
"cases": [
{"name": "ascii_short", "tokens": 1},
{"name": "whitespace_only", "tokens": 1},
{"name": "newline_only", "tokens": 1},
{"name": "cjk", "tokens": 3},
{"name": "mixed", "tokens": 4}
]

View File

@@ -0,0 +1,11 @@
{
"chunk": {
"p": "response",
"v": [
{"p": "status", "v": "CONTENT_FILTER"},
{"p": "accumulated_token_usage", "v": 77}
]
},
"thinking_enabled": false,
"current_type": "text"
}

View File

@@ -0,0 +1,8 @@
{
"chunk": {
"p": "response/content",
"v": "正常输出CONTENT_FILTER你好这个问题我暂时无法回答"
},
"thinking_enabled": false,
"current_type": "text"
}

View File

@@ -1,6 +1,8 @@
{
"cases": [
{"name": "ascii_short", "text": "abcd"},
{"name": "whitespace_only", "text": " "},
{"name": "newline_only", "text": "\n"},
{"name": "cjk", "text": "你好世界"},
{"name": "mixed", "text": "Hello 你好世界"}
]