mirror of
https://github.com/HKUDS/DeepTutor.git
synced 2026-12-02 05:59:36 +08:00
Security: lock down the TutorBot tool sandbox (shell exec is opt-in, all filesystem/shell access confined to the bot workspace) and isolate per-user resources, closing #518, #517, #516, #515, #514 and #506 (first hardened in #507). Bug fixes: chat input disabled after the first turn (#520), KB embedding failure on long documents (#521 / #509), profile creation under Docker (#512 / #513), Qwen reasoning models failing native tool calling (#527 / #528), the GPT-5 init-wizard token parameter (#508), and oversized session-event truncation (#524). Features: HTTP/SSE API for multi-turn chat with a specific TutorBot (#511), multimodal image fallback for vision-capable providers without a capability entry, safe ZIP knowledge upload, and a /settings/network page with model fetching (community PRs #522 and #523 reimplemented locally). Also bumps __version__ to 1.4.1, adds the v1.4.1 release notes, updates the README Releases section, and ships the Astro + Starlight docs site under site/. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
77 lines
2.0 KiB
Python
77 lines
2.0 KiB
Python
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
|