Refactor Planning Exercise Suggestion and Enhance LLM Integration
Deploy Development / deploy (push) Successful in 45s
Test Suite / pytest-backend (push) Successful in 40s
Test Suite / lint-backend (push) Successful in 0s
Test Suite / build-frontend (push) Successful in 13s
Test Suite / k6 /health Baseline (push) Successful in 34s
Test Suite / playwright-tests (push) Successful in 1m16s
Deploy Development / deploy (push) Successful in 45s
Test Suite / pytest-backend (push) Successful in 40s
Test Suite / lint-backend (push) Successful in 0s
Test Suite / build-frontend (push) Successful in 13s
Test Suite / k6 /health Baseline (push) Successful in 34s
Test Suite / playwright-tests (push) Successful in 1m16s
- Replaced the previous exercise matching logic with a new multistage planning retrieval process, improving the accuracy of exercise suggestions. - Introduced LLM gates to limit LLM calls based on query length and intent application, optimizing performance and resource usage. - Updated the `compose_retrieval_phase` function to include profile preselection, enhancing the retrieval process. - Incremented version to 0.5.0 and updated changelog to reflect these significant enhancements in planning AI capabilities.
This commit is contained in:
1 parent
b0611b9f7f
commit
8e68261bc1
6 files changed
+756
-275
No files matched your search
@@ -99,7 +99,52 @@ def should_run_llm_intent_pipeline(
|
||||
return False
|
||||
if scenario == SCENARIO_PRESET_NEXT:
|
||||
return False
|
||||
return bool(_normalize_query(query))
|
||||
q = _normalize_query(query)
|
||||
if not q:
|
||||
return False
|
||||
# Kurze Stichwortsuche: Volltext + Profil reichen — kein Intent-LLM
|
||||
if scenario == SCENARIO_FREE_SEARCH and len(q) < 14:
|
||||
return False
|
||||
if scenario in (SCENARIO_CONTINUE_PLAN, SCENARIO_PROGRESSION) and len(q) < 18:
|
||||
return False
|
||||
return True
|
||||
|
||||
|
||||
def deterministic_rank_confident(hits: Sequence[Mapping[str, Any]], *, gap_threshold: float = 0.12) -> bool:
|
||||
"""True wenn Hybrid-Ranking schon klar genug ist — LLM-Rerank sparen."""
|
||||
if len(hits) < 4:
|
||||
return True
|
||||
top = float(hits[0].get("score") or 0.0)
|
||||
fourth = float(hits[3].get("score") or 0.0)
|
||||
return (top - fourth) >= gap_threshold
|
||||
|
||||
|
||||
def should_run_llm_rank_pipeline(
|
||||
query: Optional[str],
|
||||
scenario: str,
|
||||
*,
|
||||
include_llm_rank: bool,
|
||||
query_intent_applied: bool,
|
||||
hits: Sequence[Mapping[str, Any]],
|
||||
) -> bool:
|
||||
"""
|
||||
Maximal ein LLM-Call pro Request: wenn Intent-LLM lief, kein Rerank.
|
||||
Rerank nur bei längerer, komplexer Anfrage und unklarem Hybrid-Ranking.
|
||||
"""
|
||||
if not include_llm_rank:
|
||||
return False
|
||||
if query_intent_applied:
|
||||
return False
|
||||
if scenario == SCENARIO_PRESET_NEXT:
|
||||
return False
|
||||
q = _normalize_query(query)
|
||||
if not q:
|
||||
return False
|
||||
if scenario == SCENARIO_ADDITIVE:
|
||||
return len(q) >= 12 and not deterministic_rank_confident(hits)
|
||||
if len(q) < 22:
|
||||
return False
|
||||
return not deterministic_rank_confident(hits)
|
||||
|
||||
|
||||
def _recalculate_skill_gap(target: PlanningTargetProfile) -> PlanningTargetProfile:
|
||||
@@ -263,8 +308,15 @@ VALID_SCENARIOS_SET = {
|
||||
}
|
||||
|
||||
|
||||
def compose_retrieval_phase(*, query_intent: bool, llm_rank: bool) -> str:
|
||||
def compose_retrieval_phase(
|
||||
*,
|
||||
profile_preselect: bool = False,
|
||||
query_intent: bool = False,
|
||||
llm_rank: bool = False,
|
||||
) -> str:
|
||||
parts = ["profile_v1"]
|
||||
if profile_preselect:
|
||||
parts.append("profile_preselect")
|
||||
if query_intent:
|
||||
parts.append("query_intent")
|
||||
if llm_rank:
|
||||
@@ -281,4 +333,6 @@ __all__ = [
|
||||
"is_simple_preset_query",
|
||||
"merge_query_overlay_into_target",
|
||||
"should_run_llm_intent_pipeline",
|
||||
"should_run_llm_rank_pipeline",
|
||||
"deterministic_rank_confident",
|
||||
]
|
||||
Reference in new issue
Block a user