Implement EvaluateStepPayload and SlotContentEntry for Enhanced Planning Features
Deploy Development / deploy (push) Successful in 42s
Test Suite / pytest-backend (push) Failing after 45s
Test Suite / lint-backend (push) Successful in 0s
Test Suite / build-frontend (push) Successful in 15s
Test Suite / k6 /health Baseline (push) Successful in 34s
Test Suite / playwright-tests (push) Successful in 1m21s
Deploy Development / deploy (push) Successful in 42s
Test Suite / pytest-backend (push) Failing after 45s
Test Suite / lint-backend (push) Successful in 0s
Test Suite / build-frontend (push) Successful in 15s
Test Suite / k6 /health Baseline (push) Successful in 34s
Test Suite / playwright-tests (push) Successful in 1m21s
- Introduced EvaluateStepPayload class to facilitate evaluation of exercise steps with optional attributes for AI proposals and roadmap details. - Added SlotContentEntry and SlotExerciseContent classes to manage exercise content within the progression graph planning artifact. - Updated GraphPlanningRoadmapArtifact to include new slot contents and last findings attributes for improved data handling. - Enhanced Exercise Progression Graph Panel with links to the new Slot Editor for streamlined editing of progression graphs. - Incremented application version to reflect these updates.
This commit is contained in:
1 parent
8d5f0b533c
commit
97efe66306
10 files changed
+1719
-4
No files matched your search
@@ -74,6 +74,18 @@ from planning_progression_roadmap import (
|
||||
from routers.training_planning import _has_planning_role
|
||||
|
||||
|
||||
class EvaluateStepPayload(BaseModel):
|
||||
exercise_id: Optional[int] = Field(default=None, ge=1)
|
||||
variant_id: Optional[int] = Field(default=None, ge=1)
|
||||
title: Optional[str] = Field(default=None, max_length=500)
|
||||
is_ai_proposal: bool = False
|
||||
ai_suggestion: Optional[Dict[str, Any]] = None
|
||||
proposal_key: Optional[str] = Field(default=None, max_length=120)
|
||||
roadmap_major_step_index: Optional[int] = Field(default=None, ge=0, le=20)
|
||||
roadmap_phase: Optional[str] = Field(default=None, max_length=80)
|
||||
roadmap_learning_goal: Optional[str] = Field(default=None, max_length=2000)
|
||||
|
||||
|
||||
class ProgressionPathSuggestRequest(BaseModel):
|
||||
query: str = Field(..., min_length=3, max_length=2000)
|
||||
max_steps: int = Field(default=5, ge=2, le=10)
|
||||
@@ -88,6 +100,8 @@ class ProgressionPathSuggestRequest(BaseModel):
|
||||
roadmap_first: bool = False
|
||||
roadmap_only: bool = False
|
||||
start_target_only: bool = False
|
||||
evaluate_only: bool = False
|
||||
evaluate_steps: Optional[List[EvaluateStepPayload]] = None
|
||||
roadmap_override: Optional[RoadmapOverridePayload] = None
|
||||
start_situation: Optional[str] = Field(default=None, max_length=2000)
|
||||
target_state: Optional[str] = Field(default=None, max_length=2000)
|
||||
@@ -606,6 +620,162 @@ def _build_steps_roadmap_first(
|
||||
return steps, unfilled
|
||||
|
||||
|
||||
def _evaluate_steps_from_payload(
|
||||
cur,
|
||||
payloads: List[EvaluateStepPayload],
|
||||
) -> List[Dict[str, Any]]:
|
||||
steps: List[Dict[str, Any]] = []
|
||||
for raw in payloads:
|
||||
is_proposal = bool(raw.is_ai_proposal) or raw.exercise_id is None
|
||||
title = (raw.title or "").strip() or None
|
||||
if is_proposal:
|
||||
steps.append(
|
||||
{
|
||||
"exercise_id": None,
|
||||
"variant_id": None,
|
||||
"title": title or "KI-Vorschlag",
|
||||
"is_ai_proposal": True,
|
||||
"ai_suggestion": raw.ai_suggestion,
|
||||
"proposal_key": raw.proposal_key,
|
||||
"roadmap_major_step_index": raw.roadmap_major_step_index,
|
||||
"roadmap_phase": raw.roadmap_phase,
|
||||
"roadmap_learning_goal": raw.roadmap_learning_goal,
|
||||
"reasons": [],
|
||||
}
|
||||
)
|
||||
continue
|
||||
eid = int(raw.exercise_id)
|
||||
cur.execute(
|
||||
"SELECT id, title, summary FROM exercises WHERE id = %s",
|
||||
(eid,),
|
||||
)
|
||||
row = cur.fetchone()
|
||||
if not row:
|
||||
raise HTTPException(status_code=400, detail=f"Übung {eid} nicht gefunden")
|
||||
steps.append(
|
||||
{
|
||||
"exercise_id": eid,
|
||||
"variant_id": raw.variant_id,
|
||||
"title": title or row.get("title"),
|
||||
"summary": row.get("summary"),
|
||||
"is_ai_proposal": False,
|
||||
"roadmap_major_step_index": raw.roadmap_major_step_index,
|
||||
"roadmap_phase": raw.roadmap_phase,
|
||||
"roadmap_learning_goal": raw.roadmap_learning_goal,
|
||||
"reasons": [],
|
||||
}
|
||||
)
|
||||
return steps
|
||||
|
||||
|
||||
def _run_evaluate_only_path_qa(
|
||||
cur,
|
||||
*,
|
||||
body: ProgressionPathSuggestRequest,
|
||||
goal_query: str,
|
||||
semantic_brief: PlanningSemanticBrief,
|
||||
steps: List[Dict[str, Any]],
|
||||
roadmap_ctx: Optional[ProgressionRoadmapContext],
|
||||
) -> Dict[str, Any]:
|
||||
roadmap_first = roadmap_ctx is not None
|
||||
gaps: List[Dict[str, Any]] = []
|
||||
bridge_inserts: List[Dict[str, Any]] = []
|
||||
unfilled_gaps: List[Dict[str, Any]] = []
|
||||
llm_qa: Optional[Dict[str, Any]] = None
|
||||
llm_qa_applied = False
|
||||
off_topic_steps: List[Dict[str, Any]] = []
|
||||
stripped_off_topic: List[Dict[str, Any]] = []
|
||||
ai_proposals: List[Dict[str, Any]] = []
|
||||
gap_fill_offers: List[Dict[str, Any]] = []
|
||||
roadmap_qa_mode: Optional[str] = None
|
||||
|
||||
if body.include_path_qa:
|
||||
if roadmap_first:
|
||||
roadmap_qa_mode = "roadmap_first_lite"
|
||||
gaps = detect_path_gaps(
|
||||
cur,
|
||||
steps,
|
||||
brief=semantic_brief,
|
||||
roadmap_first=roadmap_first,
|
||||
)
|
||||
if gaps and roadmap_first:
|
||||
unfilled_gaps = list(gaps)
|
||||
|
||||
if body.include_llm_path_qa:
|
||||
llm_qa, llm_qa_applied = try_llm_qa_progression_path(
|
||||
cur,
|
||||
goal_query=goal_query,
|
||||
brief=semantic_brief,
|
||||
steps=steps,
|
||||
gaps=gaps,
|
||||
bridge_inserts=bridge_inserts,
|
||||
)
|
||||
|
||||
off_topic_steps = detect_off_topic_steps(cur, steps, brief=semantic_brief)
|
||||
llm_gap_specs = parse_llm_suggested_new_exercises(
|
||||
llm_qa,
|
||||
brief=semantic_brief,
|
||||
step_count=len(steps),
|
||||
)
|
||||
|
||||
if body.include_ai_gap_fill:
|
||||
fresh_large_gaps = [g for g in gaps if g.get("is_large_gap")]
|
||||
gap_specs = collect_gap_fill_specs(
|
||||
steps=steps,
|
||||
unfilled_gaps=fresh_large_gaps or unfilled_gaps,
|
||||
off_topic_steps=off_topic_steps,
|
||||
llm_specs=llm_gap_specs,
|
||||
brief=semantic_brief,
|
||||
goal_query=goal_query,
|
||||
)
|
||||
path_roadmap_snapshot = None
|
||||
if roadmap_ctx:
|
||||
path_roadmap_snapshot = build_progression_gap_snapshot(
|
||||
goal_analysis=(
|
||||
roadmap_ctx.goal_analysis.model_dump()
|
||||
if roadmap_ctx.goal_analysis
|
||||
else None
|
||||
),
|
||||
resolved_structured=(
|
||||
roadmap_ctx.resolved_structured.model_dump()
|
||||
if roadmap_ctx.resolved_structured
|
||||
else None
|
||||
),
|
||||
semantic_brief=roadmap_ctx.semantic_brief
|
||||
or brief_to_summary_dict(semantic_brief),
|
||||
)
|
||||
_, ai_proposals, gap_fill_offers = apply_gap_fill_after_qa(
|
||||
cur,
|
||||
steps,
|
||||
gap_specs,
|
||||
goal_query=goal_query,
|
||||
brief=semantic_brief,
|
||||
include_ai_calls=False,
|
||||
max_ai_proposals=0,
|
||||
auto_insert_proposals=False,
|
||||
roadmap_snapshot=path_roadmap_snapshot,
|
||||
)
|
||||
|
||||
path_qa = build_path_qa_summary(
|
||||
gaps=gaps,
|
||||
bridge_inserts=bridge_inserts,
|
||||
ai_proposals=ai_proposals,
|
||||
gap_fill_offers=gap_fill_offers,
|
||||
off_topic_steps=off_topic_steps,
|
||||
stripped_off_topic=stripped_off_topic,
|
||||
llm_qa=llm_qa,
|
||||
llm_applied=llm_qa_applied,
|
||||
reorder_applied=False,
|
||||
reorder_notes=[],
|
||||
roadmap_qa_mode=roadmap_qa_mode,
|
||||
)
|
||||
return {
|
||||
"path_qa": path_qa,
|
||||
"gap_fill_offers": gap_fill_offers,
|
||||
"steps": steps,
|
||||
}
|
||||
|
||||
|
||||
def suggest_progression_path(
|
||||
cur,
|
||||
*,
|
||||
@@ -631,6 +801,7 @@ def suggest_progression_path(
|
||||
roadmap_first = bool(body.roadmap_first)
|
||||
roadmap_only = bool(body.roadmap_only)
|
||||
start_target_only = bool(body.start_target_only)
|
||||
evaluate_only = bool(body.evaluate_only)
|
||||
include_roadmap = (
|
||||
roadmap_first or body.include_roadmap_preview or roadmap_only or start_target_only
|
||||
)
|
||||
@@ -719,6 +890,42 @@ def suggest_progression_path(
|
||||
"retrieval_phase": "roadmap_only",
|
||||
}
|
||||
|
||||
if evaluate_only:
|
||||
if not body.evaluate_steps:
|
||||
raise HTTPException(
|
||||
status_code=400,
|
||||
detail="evaluate_only erfordert evaluate_steps",
|
||||
)
|
||||
eval_steps = _evaluate_steps_from_payload(cur, body.evaluate_steps)
|
||||
qa_pack = _run_evaluate_only_path_qa(
|
||||
cur,
|
||||
body=body,
|
||||
goal_query=goal_query,
|
||||
semantic_brief=semantic_brief,
|
||||
steps=eval_steps,
|
||||
roadmap_ctx=roadmap_ctx,
|
||||
)
|
||||
return {
|
||||
"goal_query": goal_query,
|
||||
"max_steps_requested": max_steps,
|
||||
"steps": qa_pack["steps"],
|
||||
"step_count": len(qa_pack["steps"]),
|
||||
"target_profile_summary": None,
|
||||
"semantic_brief_summary": brief_to_summary_dict(semantic_brief),
|
||||
"semantic_llm_applied": semantic_llm_applied,
|
||||
"query_intent_summary": {},
|
||||
"progression_graph_id": body.progression_graph_id,
|
||||
"path_qa": qa_pack["path_qa"],
|
||||
"gap_fill_offers": qa_pack["gap_fill_offers"],
|
||||
"progression_roadmap": progression_roadmap,
|
||||
"roadmap_first": bool(roadmap_ctx),
|
||||
"roadmap_only": False,
|
||||
"roadmap_edited": roadmap_edited,
|
||||
"roadmap_unfilled_count": 0,
|
||||
"path_skill_expectations": None,
|
||||
"retrieval_phase": "evaluate_only",
|
||||
}
|
||||
|
||||
path_target_profile, first_intent_summary, path_intent = _build_path_target_profile(
|
||||
cur,
|
||||
goal_query=goal_query,
|
||||
@@ -1030,6 +1237,7 @@ def suggest_progression_path(
|
||||
|
||||
|
||||
__all__ = [
|
||||
"EvaluateStepPayload",
|
||||
"ProgressionPathSuggestRequest",
|
||||
"suggest_progression_path",
|
||||
"_pick_best_path_hit",
|
||||
|
||||
Reference in new issue
Block a user