fix: prevent Peg timeout on short coaching prompts
MetaBloom CI / app (push) Canceled after 0s
MetaBloom CI / api (push) Canceled after 0s

This commit is contained in:
AI Company
2026-07-21 22:26:48 +00:00
parent 0c2430ad13
commit 7631caaa4e
2 changed files with 20 additions and 7 deletions
+16
View File
@@ -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 davoine 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")