Implement exercise_instruction_rewrite for AI Prompt System
Deploy Development / deploy (push) Successful in 44s
Test Suite / pytest-backend (push) Successful in 40s
Test Suite / lint-backend (push) Successful in 0s
Test Suite / build-frontend (push) Successful in 14s
Test Suite / k6 /health Baseline (push) Successful in 36s
Test Suite / playwright-tests (push) Successful in 1m16s
Deploy Development / deploy (push) Successful in 44s
Test Suite / pytest-backend (push) Successful in 40s
Test Suite / lint-backend (push) Successful in 0s
Test Suite / build-frontend (push) Successful in 14s
Test Suite / k6 /health Baseline (push) Successful in 36s
Test Suite / playwright-tests (push) Successful in 1m16s
- Added `exercise_instruction_rewrite` functionality to enhance AI-generated instructions, incorporating fields for goal, execution, preparation, and trainer notes. - Updated `ExerciseFormAiPromptContext` to include new fields and methods for instruction handling. - Enhanced the `run_exercise_form_ai_suggestion` function to support instruction rewriting and validation. - Modified API endpoints and frontend components to integrate instruction features, including a new button for AI instruction revision. - Incremented application version to 0.8.163 and updated changelog to reflect these changes, including migration details and new functionality.
This commit is contained in:
1 parent
5331eab39c
commit
9f4678f418
12 files changed
+623
-36
No files matched your search
@@ -218,7 +218,7 @@ def preview_ai_prompt(prompt_id: int, body: AiPromptPreviewBody, session: dict =
|
||||
|
||||
vars_map: Dict[str, str]
|
||||
warn: Optional[str] = None
|
||||
if slug in ("exercise_summary", "exercise_skill_suggestions"):
|
||||
if slug in ("exercise_summary", "exercise_skill_suggestions", "exercise_instruction_rewrite"):
|
||||
try:
|
||||
vars_map = resolve_exercise_form_variables(cur, slug, body)
|
||||
except ValueError as e:
|
||||
|
||||
@@ -367,6 +367,8 @@ class ExerciseAiSuggestBody(BaseModel):
|
||||
title: Optional[str] = Field(None, max_length=300)
|
||||
goal: Optional[str] = Field(None, max_length=64000)
|
||||
execution: Optional[str] = Field(None, max_length=128000)
|
||||
preparation: Optional[str] = Field(None, max_length=64000)
|
||||
trainer_notes: Optional[str] = Field(None, max_length=64000)
|
||||
focus_area_hint: Optional[str] = Field(None, max_length=1200)
|
||||
focus_areas_context: Optional[list[ExerciseFormAiFocusRow]] = Field(
|
||||
None,
|
||||
@@ -374,11 +376,14 @@ class ExerciseAiSuggestBody(BaseModel):
|
||||
)
|
||||
include_summary: bool = True
|
||||
include_skills: bool = True
|
||||
include_instructions: bool = False
|
||||
|
||||
@model_validator(mode="after")
|
||||
def check_include_any(self):
|
||||
if not self.include_summary and not self.include_skills:
|
||||
raise ValueError("Mindestens include_summary oder include_skills aktivieren.")
|
||||
if not self.include_summary and not self.include_skills and not self.include_instructions:
|
||||
raise ValueError(
|
||||
"Mindestens include_summary, include_skills oder include_instructions aktivieren."
|
||||
)
|
||||
return self
|
||||
|
||||
def to_form_context(self) -> ExerciseFormAiPromptContext:
|
||||
@@ -386,6 +391,8 @@ class ExerciseAiSuggestBody(BaseModel):
|
||||
title=self.title,
|
||||
goal=self.goal,
|
||||
execution=self.execution,
|
||||
preparation=self.preparation,
|
||||
trainer_notes=self.trainer_notes,
|
||||
focus_area_hint=self.focus_area_hint,
|
||||
focus_areas_context=self.focus_areas_context,
|
||||
)
|
||||
@@ -398,7 +405,7 @@ class ExerciseAiRegenerateBody(BaseModel):
|
||||
|
||||
@model_validator(mode="after")
|
||||
def normalize_regs(self):
|
||||
allowed = {"summary", "skills"}
|
||||
allowed = {"summary", "skills", "instructions"}
|
||||
raw = [str(x).strip().lower() for x in (self.regenerate or [])]
|
||||
out = []
|
||||
seen = set()
|
||||
@@ -2318,6 +2325,7 @@ def exercise_ai_suggest_endpoint(
|
||||
body.to_form_context(),
|
||||
want_summary=body.include_summary,
|
||||
want_skills=body.include_skills,
|
||||
want_instructions=body.include_instructions,
|
||||
)
|
||||
return payload
|
||||
|
||||
@@ -2331,6 +2339,7 @@ def exercise_ai_regenerate_endpoint(
|
||||
"""Neu-Anfrage KI fuer eine gespeicherte Uebung; schreibendes Ergebnis nur im Frontend (PUT)."""
|
||||
want_summary = "summary" in body.regenerate
|
||||
want_skills = "skills" in body.regenerate
|
||||
want_instructions = "instructions" in body.regenerate
|
||||
|
||||
with get_db() as conn:
|
||||
cur = get_cursor(conn)
|
||||
@@ -2347,6 +2356,8 @@ def exercise_ai_regenerate_endpoint(
|
||||
title=str(exercise.get("title") or "").strip(),
|
||||
goal=exercise.get("goal"),
|
||||
execution=exercise.get("execution"),
|
||||
preparation=exercise.get("preparation"),
|
||||
trainer_notes=exercise.get("trainer_notes"),
|
||||
focus_hint=focus or None,
|
||||
focus_tuples=fctx or None,
|
||||
)
|
||||
@@ -2355,6 +2366,7 @@ def exercise_ai_regenerate_endpoint(
|
||||
ctx,
|
||||
want_summary=want_summary,
|
||||
want_skills=want_skills,
|
||||
want_instructions=want_instructions,
|
||||
)
|
||||
return payload
|
||||
|
||||
|
||||
Reference in new issue
Block a user