sync: 鍚屾灞€鍩熺綉鏈€鏂颁唬鐮?(source master @ b69568e4)
This commit is contained in:
1 parent
4f7f07504a
commit
8bc8b0e082
1651 files changed
+278599
-11416
No files matched your search
+40
@@ -0,0 +1,40 @@
|
||||
from langchain_core.messages import AIMessage, AIMessageChunk
|
||||
|
||||
from deerflow.models.patched_openai import (
|
||||
_append_reasoning_content,
|
||||
_extract_reasoning_content,
|
||||
_restore_reasoning_content,
|
||||
)
|
||||
|
||||
|
||||
def test_extracts_legacy_reasoning_content():
|
||||
assert _extract_reasoning_content({"reasoning_content": "legacy"}) == "legacy"
|
||||
|
||||
|
||||
def test_extracts_vllm_reasoning():
|
||||
assert _extract_reasoning_content({"reasoning": "new spelling"}) == "new spelling"
|
||||
|
||||
|
||||
def test_normalizes_vllm_reasoning_for_existing_clients():
|
||||
message = AIMessageChunk(content="")
|
||||
|
||||
updated = _append_reasoning_content(message, "thinking", reasoning="thinking")
|
||||
|
||||
assert updated.additional_kwargs["reasoning_content"] == "thinking"
|
||||
assert updated.additional_kwargs["reasoning"] == "thinking"
|
||||
|
||||
|
||||
def test_restores_original_vllm_reasoning_spelling_for_follow_up_turn():
|
||||
original = AIMessage(
|
||||
content="answer",
|
||||
additional_kwargs={
|
||||
"reasoning": "thinking",
|
||||
"reasoning_content": "thinking",
|
||||
},
|
||||
)
|
||||
payload = {"role": "assistant", "content": "answer"}
|
||||
|
||||
_restore_reasoning_content(payload, original)
|
||||
|
||||
assert payload["reasoning"] == "thinking"
|
||||
assert "reasoning_content" not in payload
|
||||
Reference in new issue
Block a user