fix(api): tighten shopping suggestion response rules
Constrain shopping target concerns to SkinConcern enums and add a regression test for invalid values. Simplify the shopping prompt so repurchase suggestions stay practical, use shorter product types, and avoid leaking raw scoring/debug language into user-facing copy.
This commit is contained in:
parent
d91d06455b
commit
e20c18c2ee
2 changed files with 37 additions and 41 deletions
|
|
@ -267,6 +267,26 @@ def test_suggest_shopping_invalid_schema_returns_502(client):
|
|||
assert "suggestions/0/priority" in r.json()["detail"]
|
||||
|
||||
|
||||
def test_suggest_shopping_invalid_target_concern_returns_502(client):
|
||||
with patch(
|
||||
"innercontext.api.products.call_gemini_with_function_tools"
|
||||
) as mock_gemini:
|
||||
mock_response = type(
|
||||
"Response",
|
||||
(),
|
||||
{
|
||||
"text": '{"suggestions": [{"category": "cleanser", "product_type": "cleanser", "priority": "high", "key_ingredients": ["glycerin"], "target_concerns": ["inflammation"], "recommended_time": "am", "frequency": "daily", "short_reason": "Brakuje lagodnego kroku myjacego rano.", "reason_to_buy_now": "Obecnie nie masz delikatnego produktu do porannego oczyszczania i wsparcia bariery.", "fit_with_current_routine": "To domknie podstawowy krok cleanse bez dokladania agresywnych aktywow.", "usage_cautions": []}], "reasoning": "Test shopping"}'
|
||||
},
|
||||
)
|
||||
mock_gemini.return_value = (mock_response, None)
|
||||
|
||||
r = client.post("/products/suggest")
|
||||
|
||||
assert r.status_code == 502
|
||||
assert "LLM returned invalid shopping suggestion schema" in r.json()["detail"]
|
||||
assert "suggestions/0/target_concerns/0" in r.json()["detail"]
|
||||
|
||||
|
||||
def test_shopping_context_medication_skip(session: Session):
|
||||
p = Product(
|
||||
id=uuid.uuid4(),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue