feat(routines): add minimize_products option for batch suggestions
This commit is contained in:
parent
40f9a353bb
commit
609995732b
4 changed files with 26 additions and 4 deletions
|
|
@ -97,6 +97,7 @@ class SuggestBatchRequest(SQLModel):
|
|||
to_date: date
|
||||
notes: Optional[str] = None
|
||||
include_minoxidil_beard: bool = False
|
||||
minimize_products: Optional[bool] = None
|
||||
|
||||
|
||||
class DayPlan(SQLModel):
|
||||
|
|
@ -273,7 +274,9 @@ def _build_products_context(session: Session, time_filter: Optional[str] = None)
|
|||
product_ids = [p.id for p in products]
|
||||
inventory_rows = (
|
||||
session.exec(
|
||||
select(ProductInventory).where(col(ProductInventory.product_id).in_(product_ids))
|
||||
select(ProductInventory).where(
|
||||
col(ProductInventory.product_id).in_(product_ids)
|
||||
)
|
||||
).all()
|
||||
if product_ids
|
||||
else []
|
||||
|
|
@ -291,7 +294,7 @@ def _build_products_context(session: Session, time_filter: Optional[str] = None)
|
|||
p.inventory = inv_by_product.get(p.id, [])
|
||||
ctx = p.to_llm_context()
|
||||
entry = (
|
||||
f" - id={ctx['id']} name=\"{ctx['name']}\" brand=\"{ctx['brand']}\""
|
||||
f' - id={ctx["id"]} name="{ctx["name"]}" brand="{ctx["brand"]}"'
|
||||
f" category={ctx.get('category', '')} recommended_time={ctx.get('recommended_time', '')}"
|
||||
f" targets={ctx.get('targets', [])}"
|
||||
)
|
||||
|
|
@ -552,12 +555,17 @@ def suggest_batch(
|
|||
dates_str = "\n".join(date_range_lines)
|
||||
|
||||
notes_line = f"\nKONTEKST OD UŻYTKOWNIKA: {data.notes}\n" if data.notes else ""
|
||||
minimize_line = (
|
||||
"\nOGRANICZENIA:\n - Minimalizuj liczbę unikalnych produktów (używaj tych samych produktów wielokrotnie)\n"
|
||||
if data.minimize_products
|
||||
else ""
|
||||
)
|
||||
|
||||
prompt = (
|
||||
f"Zaproponuj plan pielęgnacji AM + PM dla każdego dnia z zakresu:\n{dates_str}\n\n"
|
||||
"DANE WEJŚCIOWE:\n"
|
||||
f"{skin_ctx}\n{grooming_ctx}\n{history_ctx}\n{products_ctx}\n{objectives_ctx}"
|
||||
f"{notes_line}\n"
|
||||
f"{notes_line}{minimize_line}"
|
||||
"\nZwróć JSON zgodny ze schematem."
|
||||
)
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue