Merge master into deploy/prod

This commit is contained in:
dadachann
2026-08-24 03:54:53 +00:00
2 changed files with 8 additions and 8 deletions
@@ -650,13 +650,13 @@ class QQOfficialAdapter(abstract_platform_adapter.AbstractMessagePlatformAdapter
# 用第一个 chunk 的文本建立会话(不发 "..." 避免污染前缀) # 用第一个 chunk 的文本建立会话(不发 "..." 避免污染前缀)
ctx['session_started'] = True ctx['session_started'] = True
# 发送内容 = 全量累积文本 # `replace` mode requires every update to contain the previously
# QQ API 的 replace 模式不允许修改已下发前缀,所以: # delivered content as its prefix. `sent_length` only tells us whether
# - 首次:发送全部文本,建立会话 # a non-final snapshot has new content; it must not truncate the
# - 后续:只能发送新增部分(append 行为) # content sent to QQ.
content_to_send = ctx['accumulated_text'][ctx['sent_length'] :] if len(ctx['accumulated_text']) <= ctx['sent_length'] and not is_final:
if not content_to_send and not is_final:
return return
content_to_send = ctx['accumulated_text']
input_state = 10 if is_final else 1 input_state = 10 if is_final else 1
@@ -108,7 +108,7 @@ def _stream_test_adapter():
@pytest.mark.asyncio @pytest.mark.asyncio
async def test_qq_stream_uses_cumulative_chunks_as_snapshots(): async def test_qq_stream_replace_mode_sends_complete_snapshots():
adapter = _stream_test_adapter() adapter = _stream_test_adapter()
adapter._stream_ctx['message-1'] = { adapter._stream_ctx['message-1'] = {
'user_openid': 'user-1', 'user_openid': 'user-1',
@@ -138,7 +138,7 @@ async def test_qq_stream_uses_cumulative_chunks_as_snapshots():
assert [call.kwargs['content'] for call in adapter.bot.send_stream_msg.await_args_list] == [ assert [call.kwargs['content'] for call in adapter.bot.send_stream_msg.await_args_list] == [
'<think>one', '<think>one',
' two', '<think>one two',
] ]