mirror of
https://github.com/CJackHwang/ds2api.git
synced 2026-05-23 10:47:43 +08:00
feat: enhance content filtering, token usage tracking, and stream error handling in chat-stream modules
This commit is contained in:
8
tests/compat/expected/sse_content_filter_status.json
Normal file
8
tests/compat/expected/sse_content_filter_status.json
Normal file
@@ -0,0 +1,8 @@
|
||||
{
|
||||
"parts": [],
|
||||
"finished": true,
|
||||
"new_type": "text",
|
||||
"content_filter": true,
|
||||
"output_tokens": 77,
|
||||
"error_message": ""
|
||||
}
|
||||
7
tests/compat/expected/sse_leaked_content_filter.json
Normal file
7
tests/compat/expected/sse_leaked_content_filter.json
Normal file
@@ -0,0 +1,7 @@
|
||||
{
|
||||
"parts": [
|
||||
{"text": "正常输出", "type": "text"}
|
||||
],
|
||||
"finished": false,
|
||||
"new_type": "text"
|
||||
}
|
||||
@@ -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}
|
||||
]
|
||||
|
||||
11
tests/compat/fixtures/sse_chunks/content_filter_status.json
Normal file
11
tests/compat/fixtures/sse_chunks/content_filter_status.json
Normal 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"
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
{
|
||||
"chunk": {
|
||||
"p": "response/content",
|
||||
"v": "正常输出CONTENT_FILTER你好,这个问题我暂时无法回答"
|
||||
},
|
||||
"thinking_enabled": false,
|
||||
"current_type": "text"
|
||||
}
|
||||
@@ -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 你好世界"}
|
||||
]
|
||||
|
||||
Reference in New Issue
Block a user