added fitness
This commit is contained in:
@@ -55,10 +55,27 @@ MEMORY_TOOL_NAMES = frozenset({
|
||||
"update_session_summary",
|
||||
})
|
||||
|
||||
FITNESS_TOOL_NAMES = frozenset({
|
||||
"get_fitness_summary",
|
||||
"set_fitness_profile",
|
||||
"calc_fitness_targets",
|
||||
"log_meal",
|
||||
"log_water",
|
||||
"log_weight",
|
||||
"log_workout",
|
||||
"lookup_food",
|
||||
"lookup_exercise",
|
||||
"set_fitness_reminder",
|
||||
})
|
||||
|
||||
# Не засорять чат служебными ответами
|
||||
TOOLS_SKIP_CHAT_NOTICE = frozenset({
|
||||
"get_pomodoro_status",
|
||||
"recall_memories",
|
||||
"get_fitness_summary",
|
||||
"lookup_food",
|
||||
"lookup_exercise",
|
||||
"calc_fitness_targets",
|
||||
})
|
||||
|
||||
|
||||
@@ -76,6 +93,8 @@ def format_tool_notice(tool_name: str, raw_result: str) -> str | None:
|
||||
prefix = "⏱"
|
||||
elif tool_name in MEMORY_TOOL_NAMES:
|
||||
prefix = "🧠"
|
||||
elif tool_name in FITNESS_TOOL_NAMES:
|
||||
prefix = "💪"
|
||||
else:
|
||||
prefix = "📋"
|
||||
return f"{prefix} {data['error']}"
|
||||
@@ -138,6 +157,39 @@ def format_tool_notice(tool_name: str, raw_result: str) -> str | None:
|
||||
if tool_name == "update_session_summary" and data.get("ok"):
|
||||
return "🧠 **Сводка чата сохранена**"
|
||||
|
||||
if tool_name == "log_meal" and data.get("ok"):
|
||||
meal = data.get("meal", {})
|
||||
est = "≈" if meal.get("estimated") else ""
|
||||
return (
|
||||
f"💪 **Приём пищи** · {meal.get('description')} · "
|
||||
f"{est}{meal.get('calories', 0):.0f} ккал "
|
||||
f"(Б{meal.get('protein_g', 0):.0f}/Ж{meal.get('fat_g', 0):.0f}/У{meal.get('carbs_g', 0):.0f})"
|
||||
)
|
||||
|
||||
if tool_name == "log_water" and data.get("ok"):
|
||||
w = data.get("water", {})
|
||||
return f"💪 **Вода** +{w.get('amount_ml')} мл"
|
||||
|
||||
if tool_name == "log_weight" and data.get("ok"):
|
||||
m = data.get("metric", {})
|
||||
return f"💪 **Вес** {m.get('weight_kg')} кг"
|
||||
|
||||
if tool_name == "log_workout" and data.get("ok"):
|
||||
wo = data.get("workout", {})
|
||||
return f"💪 **Тренировка** · {wo.get('title')}"
|
||||
|
||||
if tool_name == "set_fitness_profile" and data.get("ok"):
|
||||
p = data.get("profile", {})
|
||||
return (
|
||||
f"💪 **Профиль** · {p.get('calorie_target')} ккал, "
|
||||
f"вода {p.get('water_l')} л"
|
||||
)
|
||||
|
||||
if tool_name == "set_fitness_reminder" and data.get("ok"):
|
||||
r = data.get("reminder", {})
|
||||
state = "вкл" if r.get("enabled") else "выкл"
|
||||
return f"💪 **Напоминание {r.get('kind')}** · {state}"
|
||||
|
||||
return None
|
||||
|
||||
|
||||
|
||||
@@ -12,6 +12,7 @@ from app.chat.notices import (
|
||||
format_pomodoro_context,
|
||||
format_tool_notice,
|
||||
)
|
||||
from app.fitness.context import format_fitness_context, get_fitness_snapshot
|
||||
from app.memory.context import (
|
||||
format_identity_hint,
|
||||
format_memory_context,
|
||||
@@ -59,10 +60,12 @@ class ChatService:
|
||||
def _build_system_prompt(self, session_id: int | None = None) -> str:
|
||||
status = PomodoroService(self.db).get_status()
|
||||
memory_snapshot = get_memory_snapshot(self.db, session_id)
|
||||
fitness_snapshot = get_fitness_snapshot(self.db)
|
||||
projects_snapshot = get_projects_snapshot(self.db)
|
||||
return (
|
||||
f"{self.character.get_system_prompt()}\n\n"
|
||||
f"{format_memory_context(memory_snapshot)}\n\n"
|
||||
f"{format_fitness_context(fitness_snapshot)}\n\n"
|
||||
f"{format_pomodoro_context(status)}\n\n"
|
||||
f"{format_projects_context(projects_snapshot)}"
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user