feat: add DeepSeek extreme reasoning tier
This commit is contained in:
+44
-1
@@ -21,10 +21,15 @@ def disable_retry_sleep(monkeypatch: pytest.MonkeyPatch) -> None:
|
||||
async def _complete_with_handler(
|
||||
settings: Settings,
|
||||
handler: Callable[[httpx.Request], httpx.Response | Awaitable[httpx.Response]],
|
||||
**kwargs,
|
||||
) -> dict:
|
||||
async with httpx.AsyncClient(transport=httpx.MockTransport(handler)) as client:
|
||||
provider = ModelProvider(settings, client)
|
||||
return await provider.complete(model="test-model", messages=[{"role": "user", "content": "hello"}])
|
||||
return await provider.complete(
|
||||
model="test-model",
|
||||
messages=[{"role": "user", "content": "hello"}],
|
||||
**kwargs,
|
||||
)
|
||||
|
||||
|
||||
async def test_complete_retries_transient_gateway_response(settings: Settings) -> None:
|
||||
@@ -158,3 +163,41 @@ async def test_complete_aggregates_streamed_tool_call(settings: Settings) -> Non
|
||||
}
|
||||
]
|
||||
assert result["usage"]["total_tokens"] == 7
|
||||
|
||||
|
||||
async def test_deepseek_route_enables_thinking_and_uses_separate_credentials(settings: Settings) -> None:
|
||||
body = (
|
||||
'data: {"choices":[{"index":0,"delta":{"role":"assistant",'
|
||||
'"reasoning_content":"private state","tool_calls":[{"index":0,"id":"call-1",'
|
||||
'"type":"function","function":{"name":"ping","arguments":"{}"}}]},'
|
||||
'"finish_reason":"tool_calls"}]}\n\n'
|
||||
"data: [DONE]\n\n"
|
||||
)
|
||||
|
||||
def handler(request: httpx.Request) -> httpx.Response:
|
||||
assert str(request.url) == "https://api.deepseek.example.test/v1/chat/completions"
|
||||
assert request.headers["Authorization"] == "Bearer deepseek-secret"
|
||||
payload = json.loads(request.content)
|
||||
assert payload["model"] == "test-model"
|
||||
assert payload["thinking"] == {"type": "enabled"}
|
||||
assert payload["reasoning_effort"] == "max"
|
||||
assert payload["max_tokens"] == 16_384
|
||||
return httpx.Response(
|
||||
200,
|
||||
request=request,
|
||||
headers={"Content-Type": "text/event-stream"},
|
||||
content=body,
|
||||
)
|
||||
|
||||
result = await _complete_with_handler(
|
||||
settings,
|
||||
handler,
|
||||
provider="deepseek",
|
||||
thinking_enabled=True,
|
||||
reasoning_effort="max",
|
||||
max_output_tokens=16_384,
|
||||
)
|
||||
|
||||
message = result["choices"][0]["message"]
|
||||
assert message["reasoning_content"] == "private state"
|
||||
assert message["tool_calls"][0]["function"]["name"] == "ping"
|
||||
|
||||
Reference in New Issue
Block a user