Refactor Catalog Prompt Slot Management and Enhance Fallback Logic
Deploy Development / deploy (push) Successful in 40s
Test Suite / pytest-backend (push) Failing after 2s
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 1m22s

- Introduced a new function `_resolve_entry_slot_values` to streamline the merging of stored slot values with fallbacks, improving code clarity and maintainability.
- Updated `get_catalog_entry_slots` and `resolve_catalog_prompt_variables` functions to utilize the new fallback logic, enhancing the handling of catalog entries.
- Enhanced the `CatalogPromptSlotsEditor` component to display fallback information for slots, improving user experience in managing catalog prompts.
- Incremented version numbers and updated changelog to reflect the new features and improvements.
This commit is contained in:
Lars committed 2026-06-15 15:18:00 +02:00
1 parent 53f2b027cc
commit 7e5ef4561a
7 files changed
+546 -23

No files matched your search

@@ -0,0 +1,38 @@
"""Tests Namens-Fallback für Katalog-Prompt-Slots."""
from catalog_slot_fallbacks import get_fallback_slots_for_entry, merge_stored_slots_with_fallbacks
from catalog_prompt_slots import _resolve_entry_slot_values
def test_karate_fallback_has_path_qa():
pack = get_fallback_slots_for_entry("focus_area", "Karate")
assert "Kohärente Progression" in pack.get("hints_on_path_qa", "")
def test_db_value_overrides_fallback():
merged = merge_stored_slots_with_fallbacks(
{"hints_on_path_qa": "Eigener QS-Text."},
catalog_kind="focus_area",
name="Karate",
stammdaten_description="Traditionelles Karate",
)
assert merged["hints_on_path_qa"] == "Eigener QS-Text."
def test_empty_db_uses_karate_fallback():
merged = _resolve_entry_slot_values(
{},
{"name": "Karate", "description": "Traditionelles Karate"},
"focus_area",
)
assert "Kihon-Progression" in merged["description"] or "Technik-Curriculum" in merged["description"]
assert "Kohärente Progression" in merged["hints_on_path_qa"]
def test_gewaltschutz_fallback_no_kumite():
merged = _resolve_entry_slot_values(
{},
{"name": "Gewaltschutz", "description": "Gewaltprävention"},
"focus_area",
)
assert "Deeskalation" in merged["hints_on_path_qa"]
assert "Kumite-Tiefe" in merged["anti_patterns"]
@@ -90,13 +90,13 @@ def test_granular_placeholder_focus_area_hints_on_path_qa():
assert resolved["has_catalog_guidance"] == "true"
def test_description_fallback_from_stammdaten():
def test_unknown_focus_uses_default_description_pack():
cur = _mock_cur(
rows_by_table={
"focus_areas": {
4: {
"name": "Gewaltschutz",
"description": "Gewaltprävention und Deeskalation",
"name": "Sonderfokus Alpha",
"description": "Kurze Stammdaten-Beschreibung",
}
}
},
@@ -106,7 +106,9 @@ def test_description_fallback_from_stammdaten():
focus_areas=[PlanningCatalogContextItem(id=4, is_primary=True)],
)
resolved = resolve_catalog_prompt_variables(cur, catalog)
assert resolved[placeholder_key("focus_area", "description")] == "Gewaltprävention und Deeskalation"
desc = resolved[placeholder_key("focus_area", "description")]
assert "Technik- oder Themen-Curriculum" in desc
assert resolved[placeholder_key("focus_area", "hints_on_path_qa")]
def test_empty_without_catalog():
@@ -116,15 +118,15 @@ def test_empty_without_catalog():
assert out["catalog_guidance_block"] == ""
def test_unknown_entry_no_guidance_block():
def test_unknown_entry_gets_default_technique_fallback():
cur = _mock_cur(rows_by_table={"focus_areas": {99: {"name": "Unbekannter Fokus XYZ"}}})
catalog = ProgressionPlanningCatalogContext(
focus_areas=[PlanningCatalogContextItem(id=99, is_primary=True)],
)
out = build_catalog_guidance_for_prompt(cur, catalog)
assert out["has_catalog_guidance"] is False
assert out["catalog_guidance_block"] == ""
assert out["has_catalog_guidance"] is True
assert "Unbekannter Fokus XYZ" in out["catalog_context_json"]
assert "Zwischenstufen" in out["catalog_guidance_block"] or "Progression" in out["catalog_guidance_block"]
def test_merge_planning_prompt_variables_granular_keys():