Implement Roadmap-First Retrieval and Enhance Planning AI Features
Deploy Development / deploy (push) Successful in 43s
Test Suite / pytest-backend (push) Successful in 43s
Test Suite / lint-backend (push) Successful in 0s
Test Suite / build-frontend (push) Successful in 14s
Test Suite / k6 /health Baseline (push) Successful in 34s
Test Suite / playwright-tests (push) Successful in 1m26s
Deploy Development / deploy (push) Successful in 43s
Test Suite / pytest-backend (push) Successful in 43s
Test Suite / lint-backend (push) Successful in 0s
Test Suite / build-frontend (push) Successful in 14s
Test Suite / k6 /health Baseline (push) Successful in 34s
Test Suite / playwright-tests (push) Successful in 1m26s
- Introduced a roadmap-first approach for retrieval, allowing for structured exercise suggestions based on stage specifications and major steps. - Added functionality to generate gap-fill offers for unfilled roadmap stages, improving the relevance of exercise recommendations. - Updated the `ExerciseProgressionPathBuilder` to support the new roadmap-first feature, enhancing user experience with clearer exercise paths. - Incremented application version to 0.8.206 and updated the database schema version to reflect these changes.
This commit is contained in:
1 parent
7411543a97
commit
d4e9bded23
10 files changed
+431
-52
No files matched your search
@@ -13,7 +13,7 @@ from __future__ import annotations
|
||||
import json
|
||||
import logging
|
||||
import re
|
||||
from typing import Any, Dict, List, Optional, Sequence, Tuple
|
||||
from typing import Any, Dict, List, Mapping, Optional, Sequence, Tuple
|
||||
|
||||
from pydantic import BaseModel, Field, ValidationError
|
||||
|
||||
@@ -421,6 +421,107 @@ def consolidate_micro_to_major(
|
||||
return majors, notes
|
||||
|
||||
|
||||
def _normalize_query(query: Optional[str]) -> str:
|
||||
return re.sub(r"\s+", " ", (query or "").strip())
|
||||
|
||||
|
||||
def stage_spec_retrieval_query(
|
||||
*,
|
||||
semantic_brief: PlanningSemanticBrief,
|
||||
goal_query: str,
|
||||
stage_spec: StageSpecArtifact,
|
||||
major_step: Optional[MajorStep] = None,
|
||||
) -> str:
|
||||
"""Retrieval-Query für einen Roadmap-Major-Step (Phase F3)."""
|
||||
parts: List[str] = []
|
||||
topic = (semantic_brief.primary_topic or semantic_brief.retrieval_query or goal_query).strip()
|
||||
if topic:
|
||||
parts.append(topic)
|
||||
learning_goal = (stage_spec.learning_goal or "").strip()
|
||||
if learning_goal:
|
||||
parts.append(learning_goal)
|
||||
phase = (major_step.phase if major_step else "").strip().lower()
|
||||
if phase:
|
||||
parts.append(phase)
|
||||
if stage_spec.load_profile:
|
||||
parts.extend(str(x).strip() for x in stage_spec.load_profile[:2] if str(x).strip())
|
||||
exercise_type = (stage_spec.exercise_type or "").strip().lower()
|
||||
if exercise_type == "partner_drill":
|
||||
parts.append("partner")
|
||||
elif exercise_type == "kombination":
|
||||
parts.append("kombination")
|
||||
return _normalize_query(" ".join(parts)) or _normalize_query(goal_query)
|
||||
|
||||
|
||||
def stage_spec_exercise_kind_filter(stage_spec: StageSpecArtifact) -> Optional[List[str]]:
|
||||
"""Mappt didaktischen exercise_type auf DB exercise_kind (simple/combination)."""
|
||||
et = (stage_spec.exercise_type or "").strip().lower()
|
||||
if et == "kombination":
|
||||
return ["combination"]
|
||||
if et in ("kihon_einzel", "partner_drill", "grundtechnik"):
|
||||
return ["simple"]
|
||||
return None
|
||||
|
||||
|
||||
def resolve_step_exercise_kind_filter(
|
||||
stage_spec: StageSpecArtifact,
|
||||
request_filter: Optional[Sequence[str]],
|
||||
) -> Optional[List[str]]:
|
||||
"""Schnittmenge aus Roadmap-Stufe und optionalem Request-Filter."""
|
||||
stage_filter = stage_spec_exercise_kind_filter(stage_spec)
|
||||
if not request_filter:
|
||||
return stage_filter
|
||||
req = [str(x).strip().lower() for x in request_filter if str(x).strip()]
|
||||
if not stage_filter:
|
||||
return req or None
|
||||
merged = [k for k in stage_filter if k in req]
|
||||
return merged or req
|
||||
|
||||
|
||||
def build_roadmap_unfilled_gap_specs(
|
||||
*,
|
||||
unfilled_specs: Sequence[Tuple[int, StageSpecArtifact]],
|
||||
major_steps_by_index: Mapping[int, MajorStep],
|
||||
steps: Sequence[Mapping[str, Any]],
|
||||
brief: PlanningSemanticBrief,
|
||||
goal_query: str,
|
||||
) -> List[Dict[str, Any]]:
|
||||
"""Gap-Fill-Angebote für Roadmap-Stufen ohne Bibliothekstreffer."""
|
||||
topic = (brief.primary_topic or "Technik").strip()
|
||||
specs: List[Dict[str, Any]] = []
|
||||
for roadmap_idx, stage_spec in unfilled_specs:
|
||||
major = major_steps_by_index.get(stage_spec.major_step_index)
|
||||
phase = (major.phase if major else "vertiefung").strip().lower()
|
||||
insert_after = min(max(roadmap_idx - 1, -1), max(len(steps) - 1, -1))
|
||||
title_hint = (stage_spec.learning_goal or f"{topic} — {phase}").strip()[:120]
|
||||
sketch_parts = [
|
||||
f"Planungsziel: {goal_query}",
|
||||
f"Roadmap-Stufe {stage_spec.major_step_index + 1} ({phase}): {stage_spec.learning_goal}",
|
||||
]
|
||||
if stage_spec.success_criteria:
|
||||
sketch_parts.append(f"Erfolgskriterien: {', '.join(stage_spec.success_criteria[:3])}")
|
||||
specs.append(
|
||||
{
|
||||
"source": "roadmap_unfilled",
|
||||
"insert_after_index": insert_after,
|
||||
"gap": {
|
||||
"expected_phase": phase,
|
||||
"roadmap_major_step_index": stage_spec.major_step_index,
|
||||
"learning_goal": stage_spec.learning_goal,
|
||||
},
|
||||
"phase": phase,
|
||||
"title_hint": title_hint,
|
||||
"sketch": "\n".join(sketch_parts),
|
||||
"rationale": (
|
||||
f"Keine passende Bibliotheks-Übung für Roadmap-Stufe "
|
||||
f"{stage_spec.major_step_index + 1} ({phase})."
|
||||
),
|
||||
"roadmap_major_step_index": stage_spec.major_step_index,
|
||||
}
|
||||
)
|
||||
return specs[:5]
|
||||
|
||||
|
||||
def build_stage_specs(
|
||||
major_steps: Sequence[MajorStep],
|
||||
*,
|
||||
@@ -553,7 +654,11 @@ __all__ = [
|
||||
"RoadmapArtifact",
|
||||
"StageSpecArtifact",
|
||||
"build_goal_analysis",
|
||||
"build_roadmap_unfilled_gap_specs",
|
||||
"build_stage_specs",
|
||||
"resolve_step_exercise_kind_filter",
|
||||
"stage_spec_exercise_kind_filter",
|
||||
"stage_spec_retrieval_query",
|
||||
"consolidate_micro_to_major",
|
||||
"develop_micro_objectives",
|
||||
"progression_roadmap_to_api_dict",
|
||||
|
||||
Reference in new issue
Block a user