feat(profile): add profile settings and LLM user context
This commit is contained in:
parent
db3d9514d5
commit
b99b9ed68e
25 changed files with 472 additions and 9 deletions
|
|
@ -11,15 +11,26 @@ from innercontext.api.products import (
|
|||
_build_shopping_context,
|
||||
_extract_requested_product_ids,
|
||||
)
|
||||
from innercontext.models import Product, ProductInventory, SkinConditionSnapshot
|
||||
from innercontext.models import (
|
||||
Product,
|
||||
ProductInventory,
|
||||
SexAtBirth,
|
||||
SkinConditionSnapshot,
|
||||
)
|
||||
from innercontext.models.profile import UserProfile
|
||||
|
||||
|
||||
def test_build_shopping_context(session: Session):
|
||||
# Empty context
|
||||
ctx = _build_shopping_context(session)
|
||||
ctx = _build_shopping_context(session, reference_date=date.today())
|
||||
assert "USER PROFILE: no data" in ctx
|
||||
assert "(brak danych)" in ctx
|
||||
assert "POSIADANE PRODUKTY" in ctx
|
||||
|
||||
profile = UserProfile(birth_date=date(1990, 1, 10), sex_at_birth=SexAtBirth.MALE)
|
||||
session.add(profile)
|
||||
session.commit()
|
||||
|
||||
# Add snapshot
|
||||
snap = SkinConditionSnapshot(
|
||||
id=uuid.uuid4(),
|
||||
|
|
@ -54,7 +65,10 @@ def test_build_shopping_context(session: Session):
|
|||
session.add(inv)
|
||||
session.commit()
|
||||
|
||||
ctx = _build_shopping_context(session)
|
||||
ctx = _build_shopping_context(session, reference_date=date(2026, 3, 5))
|
||||
assert "USER PROFILE:" in ctx
|
||||
assert "Age: 36" in ctx
|
||||
assert "Sex at birth: male" in ctx
|
||||
assert "Typ skóry: combination" in ctx
|
||||
assert "Nawilżenie: 3/5" in ctx
|
||||
assert "Wrażliwość: 4/5" in ctx
|
||||
|
|
@ -91,6 +105,7 @@ def test_suggest_shopping(client, session):
|
|||
assert data["suggestions"][0]["product_type"] == "cleanser"
|
||||
assert data["reasoning"] == "Test shopping"
|
||||
kwargs = mock_gemini.call_args.kwargs
|
||||
assert "USER PROFILE:" in kwargs["contents"]
|
||||
assert "function_handlers" in kwargs
|
||||
assert "get_product_inci" in kwargs["function_handlers"]
|
||||
assert "get_product_safety_rules" in kwargs["function_handlers"]
|
||||
|
|
@ -111,7 +126,7 @@ def test_shopping_context_medication_skip(session: Session):
|
|||
session.add(p)
|
||||
session.commit()
|
||||
|
||||
ctx = _build_shopping_context(session)
|
||||
ctx = _build_shopping_context(session, reference_date=date.today())
|
||||
assert "Epiduo" not in ctx
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue