From 28fb74b9bf26ce75c4cfc8d45060f66457b49268 Mon Sep 17 00:00:00 2001 From: Piotr Oleszczyk Date: Tue, 3 Mar 2026 20:24:56 +0100 Subject: [PATCH] refactor(routines): translate prompt input keys to english to reduce language switch penalty --- backend/innercontext/api/routines.py | 48 ++++++++++++++-------------- 1 file changed, 24 insertions(+), 24 deletions(-) diff --git a/backend/innercontext/api/routines.py b/backend/innercontext/api/routines.py index 3e21148..7910aa7 100644 --- a/backend/innercontext/api/routines.py +++ b/backend/innercontext/api/routines.py @@ -203,16 +203,16 @@ def _build_skin_context(session: Session) -> str: ) ).first() if snapshot is None: - return "STAN SKÓRY: brak danych\n" + return "SKIN CONDITION: no data\n" ev = _ev return ( - f"STAN SKÓRY (snapshot z {snapshot.snapshot_date}):\n" - f" Ogólny stan: {ev(snapshot.overall_state)}\n" - f" Nawilżenie: {snapshot.hydration_level}/5\n" - f" Bariera: {ev(snapshot.barrier_state)}\n" - f" Aktywne problemy: {', '.join(ev(c) for c in (snapshot.active_concerns or []))}\n" - f" Priorytety: {', '.join(snapshot.priorities or [])}\n" - f" Uwagi: {snapshot.notes or 'brak'}\n" + f"SKIN CONDITION (snapshot from {snapshot.snapshot_date}):\n" + f" Overall state: {ev(snapshot.overall_state)}\n" + f" Hydration: {snapshot.hydration_level}/5\n" + f" Barrier: {ev(snapshot.barrier_state)}\n" + f" Active concerns: {', '.join(ev(c) for c in (snapshot.active_concerns or []))}\n" + f" Priorities: {', '.join(snapshot.priorities or [])}\n" + f" Notes: {snapshot.notes or 'none'}\n" ) @@ -223,8 +223,8 @@ def _build_grooming_context( select(GroomingSchedule).order_by(col(GroomingSchedule.day_of_week)) ).all() if not entries: - return "HARMONOGRAM PIELĘGNACJI: brak\n" - lines = ["HARMONOGRAM PIELĘGNACJI:"] + return "GROOMING SCHEDULE: none\n" + lines = ["GROOMING SCHEDULE:"] for e in entries: if weekdays is not None and e.day_of_week not in weekdays: continue @@ -235,7 +235,7 @@ def _build_grooming_context( f" {day_name}: {_ev(e.action)}" + (f" ({e.notes})" if e.notes else "") ) if len(lines) == 1: - lines.append(" (brak wpisów dla podanych dni)") + lines.append(" (no entries for specified days)") return "\n".join(lines) + "\n" @@ -247,8 +247,8 @@ def _build_recent_history(session: Session) -> str: .order_by(col(Routine.routine_date).desc()) ).all() if not routines: - return "OSTATNIE RUTYNY: brak\n" - lines = ["OSTATNIE RUTYNY:"] + return "RECENT ROUTINES: none\n" + lines = ["RECENT ROUTINES:"] for r in routines: steps = session.exec( select(RoutineStep) @@ -302,7 +302,7 @@ def _build_products_context( if pid: recent_usage_counts[pid] = recent_usage_counts.get(pid, 0) + 1 - lines = ["DOSTĘPNE PRODUKTY:"] + lines = ["AVAILABLE PRODUCTS:"] for p in products: if p.is_medication and not _is_minoxidil_product(p): continue @@ -364,9 +364,9 @@ def _build_products_context( def _build_objectives_context(include_minoxidil_beard: bool) -> str: if include_minoxidil_beard: return ( - "CELE UŻYTKOWNIKA:\n" - " - Priorytet: poprawa gęstości brody i wąsów\n" - " - Jeśli dostępny produkt z minoksydylem, uwzględnij go zgodnie z zasadami bezpieczeństwa\n" + "USER OBJECTIVES:\n" + " - Priority: improve beard and mustache density\n" + " - If a product with minoxidil is available, include it adhering strictly to safety rules\n" ) return "" @@ -374,8 +374,8 @@ def _build_objectives_context(include_minoxidil_beard: bool) -> str: def _build_day_context(leaving_home: Optional[bool]) -> str: if leaving_home is None: return "" - val = "tak" if leaving_home else "nie" - return f"KONTEKST DNIA:\n Wyjście z domu: {val}\n" + val = "yes" if leaving_home else "no" + return f"DAY CONTEXT:\n Leaving home: {val}\n" _ROUTINES_SYSTEM_PROMPT = """\ @@ -503,13 +503,13 @@ def suggest_routine( ) objectives_ctx = _build_objectives_context(data.include_minoxidil_beard) - notes_line = f"\nKONTEKST OD UŻYTKOWNIKA: {data.notes}\n" if data.notes else "" + notes_line = f"\nUSER CONTEXT: {data.notes}\n" if data.notes else "" day_name = _DAY_NAMES[weekday] prompt = ( f"Zaproponuj rutynę pielęgnacyjną {data.part_of_day.value.upper()} " f"na {data.routine_date} ({day_name}).\n\n" - "DANE WEJŚCIOWE:\n" + "INPUT DATA:\n" f"{skin_ctx}\n{grooming_ctx}\n{history_ctx}\n{day_ctx}\n{products_ctx}\n{objectives_ctx}" f"{notes_line}\n" "Zwróć JSON zgodny ze schematem." @@ -578,16 +578,16 @@ def suggest_batch( date_range_lines.append(f" {d} ({_DAY_NAMES[d.weekday()]})") dates_str = "\n".join(date_range_lines) - notes_line = f"\nKONTEKST OD UŻYTKOWNIKA: {data.notes}\n" if data.notes else "" + notes_line = f"\nUSER CONTEXT: {data.notes}\n" if data.notes else "" minimize_line = ( - "\nOGRANICZENIA:\n - Minimalizuj liczbę unikalnych produktów (używaj tych samych produktów wielokrotnie)\n" + "\nCONSTRAINTS:\n - Minimize number of unique products (reuse the same products multiple times)\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" + "INPUT DATA:\n" f"{skin_ctx}\n{grooming_ctx}\n{history_ctx}\n{products_ctx}\n{objectives_ctx}" f"{notes_line}{minimize_line}" "\nZwróć JSON zgodny ze schematem."