refactor(backend): consolidate product LLM function tools
This commit is contained in:
parent
b99b9ed68e
commit
40d26514a1
6 changed files with 172 additions and 380 deletions
|
|
@ -5,11 +5,9 @@ from unittest.mock import patch
|
|||
from sqlmodel import Session
|
||||
|
||||
from innercontext.api.products import (
|
||||
_build_actives_tool_handler,
|
||||
_build_inci_tool_handler,
|
||||
_build_safety_rules_tool_handler,
|
||||
_build_shopping_context,
|
||||
_extract_requested_product_ids,
|
||||
build_product_details_tool_handler,
|
||||
)
|
||||
from innercontext.models import (
|
||||
Product,
|
||||
|
|
@ -107,9 +105,7 @@ def test_suggest_shopping(client, session):
|
|||
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"]
|
||||
assert "get_product_actives" in kwargs["function_handlers"]
|
||||
assert "get_product_details" in kwargs["function_handlers"]
|
||||
|
||||
|
||||
def test_shopping_context_medication_skip(session: Session):
|
||||
|
|
@ -154,11 +150,7 @@ def test_shopping_tool_handlers_return_payloads(session: Session):
|
|||
|
||||
payload = {"product_ids": [str(product.id)]}
|
||||
|
||||
inci_data = _build_inci_tool_handler([product])(payload)
|
||||
assert inci_data["products"][0]["inci"] == ["Water", "Niacinamide"]
|
||||
|
||||
actives_data = _build_actives_tool_handler([product])(payload)
|
||||
assert actives_data["products"][0]["actives"][0]["name"] == "Niacinamide"
|
||||
|
||||
safety_data = _build_safety_rules_tool_handler([product])(payload)
|
||||
assert "context_rules" in safety_data["products"][0]
|
||||
details = build_product_details_tool_handler([product])(payload)
|
||||
assert details["products"][0]["inci"] == ["Water", "Niacinamide"]
|
||||
assert details["products"][0]["actives"][0]["name"] == "Niacinamide"
|
||||
assert "context_rules" in details["products"][0]
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue