mirror of
https://github.com/pewdiepie-archdaemon/odysseus.git
synced 2026-06-17 02:05:22 -04:00
fix(llm): route harmony thinking streams (#2449)
This commit is contained in:
@@ -172,3 +172,37 @@ def test_registered_thinking_model_stray_close_tag_repair_unchanged(monkeypatch)
|
||||
assert deltas, deltas
|
||||
first = deltas[0]["delta"]
|
||||
assert first.startswith("<think>"), f"expected repair prefix, got: {first!r}"
|
||||
|
||||
|
||||
def test_thinking_field_emits_thinking_chunk(monkeypatch):
|
||||
deltas = _run_stream(
|
||||
"gpt-oss:20b",
|
||||
[
|
||||
'data: {"choices":[{"delta":{"thinking":"checking files"}}]}',
|
||||
'data: {"choices":[{"delta":{"content":"visible answer"}}]}',
|
||||
"data: [DONE]",
|
||||
],
|
||||
monkeypatch,
|
||||
)
|
||||
assert any(d.get("thinking") and d["delta"] == "checking files" for d in deltas), deltas
|
||||
assert any((not d.get("thinking")) and d["delta"] == "visible answer" for d in deltas), deltas
|
||||
|
||||
def test_harmony_analysis_channel_routes_to_thinking(monkeypatch):
|
||||
deltas = _run_stream(
|
||||
"gpt-oss:20b",
|
||||
[
|
||||
'data: {"choices":[{"delta":{"content":"<|channel|>ana"}}]}',
|
||||
'data: {"choices":[{"delta":{"content":"lysis<|message|>We need to inspect."}}]}',
|
||||
'data: {"choices":[{"delta":{"content":"<|end|><|channel|>final<|message|>Here "}}]}',
|
||||
'data: {"choices":[{"delta":{"content":"are the files.<|end|>"}}]}',
|
||||
"data: [DONE]",
|
||||
],
|
||||
monkeypatch,
|
||||
)
|
||||
thinking = "".join(d["delta"] for d in deltas if d.get("thinking"))
|
||||
answer = "".join(d["delta"] for d in deltas if not d.get("thinking"))
|
||||
|
||||
assert thinking == "We need to inspect."
|
||||
assert answer == "Here are the files."
|
||||
assert "<|channel|>" not in thinking + answer
|
||||
assert "<|message|>" not in thinking + answer
|
||||
|
||||
Reference in New Issue
Block a user