chore: import upstream snapshot with attribution
Tests / Import Check (Python 3.13) (push) Has been cancelled
Tests / Import Check (Python 3.14) (push) Has been cancelled
Tests / Python Tests (Python 3.11) (push) Has been cancelled
Tests / Python Tests (Python 3.12) (push) Has been cancelled
Tests / Python Tests (Python 3.14) (push) Has been cancelled
Tests / Test Summary (push) Has been cancelled
Tests / Lint and Format (push) Has been cancelled
Tests / Web Node Tests (push) Has been cancelled
Tests / Import Check (Python 3.11) (push) Has been cancelled
Tests / Import Check (Python 3.12) (push) Has been cancelled
Tests / Python Tests (Python 3.13) (push) Has been cancelled
Tests / Import Check (Python 3.13) (push) Has been cancelled
Tests / Import Check (Python 3.14) (push) Has been cancelled
Tests / Python Tests (Python 3.11) (push) Has been cancelled
Tests / Python Tests (Python 3.12) (push) Has been cancelled
Tests / Python Tests (Python 3.14) (push) Has been cancelled
Tests / Test Summary (push) Has been cancelled
Tests / Lint and Format (push) Has been cancelled
Tests / Web Node Tests (push) Has been cancelled
Tests / Import Check (Python 3.11) (push) Has been cancelled
Tests / Import Check (Python 3.12) (push) Has been cancelled
Tests / Python Tests (Python 3.13) (push) Has been cancelled
This commit is contained in:
@@ -0,0 +1,76 @@
|
||||
from __future__ import annotations
|
||||
|
||||
from types import SimpleNamespace
|
||||
|
||||
|
||||
class _FakeClient:
|
||||
captured: list[dict] = []
|
||||
|
||||
def __init__(self, *, timeout: float):
|
||||
self.timeout = timeout
|
||||
|
||||
def __enter__(self):
|
||||
return self
|
||||
|
||||
def __exit__(self, *_args):
|
||||
return None
|
||||
|
||||
def post(self, url: str, *, headers: dict, json: dict):
|
||||
self.captured.append({"url": url, "headers": headers, "json": json})
|
||||
return SimpleNamespace(status_code=200, text="")
|
||||
|
||||
|
||||
def test_probe_llm_uses_max_completion_tokens_for_gpt5(monkeypatch) -> None:
|
||||
from deeptutor_cli import init_wizard
|
||||
|
||||
_FakeClient.captured = []
|
||||
monkeypatch.setattr(init_wizard.httpx, "Client", _FakeClient)
|
||||
|
||||
ok, _elapsed_ms, error = init_wizard.probe_llm(
|
||||
base_url="https://example.test/v1",
|
||||
api_key="sk-test",
|
||||
binding="openai",
|
||||
model="gpt-5-mini",
|
||||
)
|
||||
|
||||
assert ok is True
|
||||
assert error == ""
|
||||
body = _FakeClient.captured[0]["json"]
|
||||
assert body["max_completion_tokens"] == 1
|
||||
assert "max_tokens" not in body
|
||||
|
||||
|
||||
def test_probe_llm_keeps_max_tokens_for_legacy_chat_models(monkeypatch) -> None:
|
||||
from deeptutor_cli import init_wizard
|
||||
|
||||
_FakeClient.captured = []
|
||||
monkeypatch.setattr(init_wizard.httpx, "Client", _FakeClient)
|
||||
|
||||
init_wizard.probe_llm(
|
||||
base_url="https://example.test/v1",
|
||||
api_key="sk-test",
|
||||
binding="openai",
|
||||
model="gpt-3.5-turbo",
|
||||
)
|
||||
|
||||
body = _FakeClient.captured[0]["json"]
|
||||
assert body["max_tokens"] == 1
|
||||
assert "max_completion_tokens" not in body
|
||||
|
||||
|
||||
def test_probe_llm_keeps_anthropic_native_max_tokens(monkeypatch) -> None:
|
||||
from deeptutor_cli import init_wizard
|
||||
|
||||
_FakeClient.captured = []
|
||||
monkeypatch.setattr(init_wizard.httpx, "Client", _FakeClient)
|
||||
|
||||
init_wizard.probe_llm(
|
||||
base_url="https://api.anthropic.test/v1",
|
||||
api_key="sk-test",
|
||||
binding="anthropic",
|
||||
model="claude-sonnet-4",
|
||||
)
|
||||
|
||||
body = _FakeClient.captured[0]["json"]
|
||||
assert body["max_tokens"] == 1
|
||||
assert "max_completion_tokens" not in body
|
||||
Reference in New Issue
Block a user