fix: prevent Peg timeout on short coaching prompts
This commit is contained in:
@@ -80,6 +80,22 @@ def test_coach_openai_compatible_response(monkeypatch):
|
||||
assert response.json()["assistant"] == "Peg"
|
||||
|
||||
|
||||
def test_breakfast_suggestion_uses_short_model_request(monkeypatch):
|
||||
captured = {}
|
||||
|
||||
async def fake_post(self, url, **kwargs):
|
||||
captured.update(kwargs["json"])
|
||||
request = httpx.Request("POST", url)
|
||||
return httpx.Response(200, request=request, json={"choices": [{"message": {"content": "Essaie un yaourt nature, des flocons d’avoine et un fruit."}}]})
|
||||
|
||||
monkeypatch.setattr(httpx.AsyncClient, "post", fake_post)
|
||||
with TestClient(app) as client:
|
||||
response = client.post("/coach/chat", headers=auth(client), json={"message": "Une idée de petit-déjeuner"})
|
||||
assert response.status_code == 200
|
||||
assert response.json()["source"] == "model"
|
||||
assert captured["max_tokens"] == 90
|
||||
|
||||
|
||||
def test_coach_fallback_when_provider_is_down(monkeypatch):
|
||||
async def failed_post(self, url, **kwargs):
|
||||
raise httpx.ConnectError("offline")
|
||||
|
||||
Reference in New Issue
Block a user