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
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:
1 parent
53f2b027cc
commit
7e5ef4561a
7 files changed
+546
-23
No files matched your search
@@ -15,6 +15,7 @@ from planning_catalog_context import (
|
||||
PlanningCatalogContextItem,
|
||||
catalog_context_has_items,
|
||||
)
|
||||
from catalog_slot_fallbacks import merge_stored_slots_with_fallbacks
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
# Dimensionen (Prioritätsreihenfolge)
|
||||
@@ -196,6 +197,20 @@ def _fallback_slot_type_rows() -> List[Dict[str, Any]]:
|
||||
return rows
|
||||
|
||||
|
||||
def _resolve_entry_slot_values(
|
||||
stored: Mapping[str, str],
|
||||
row: Mapping[str, Any],
|
||||
catalog_kind: str,
|
||||
) -> Dict[str, str]:
|
||||
"""DB → Namens-Fallback → Stammdaten-Beschreibung (nur description)."""
|
||||
return merge_stored_slots_with_fallbacks(
|
||||
stored,
|
||||
catalog_kind=catalog_kind,
|
||||
name=str(row.get("name") or ""),
|
||||
stammdaten_description=str(row.get("description") or ""),
|
||||
)
|
||||
|
||||
|
||||
def get_catalog_entry_slots(cur, catalog_kind: str, catalog_id: int) -> Dict[str, Any]:
|
||||
cfg = _KIND_BY_NAME.get((catalog_kind or "").strip())
|
||||
if not cfg:
|
||||
@@ -204,17 +219,13 @@ def get_catalog_entry_slots(cur, catalog_kind: str, catalog_id: int) -> Dict[str
|
||||
if not row:
|
||||
raise LookupError("Katalog-Eintrag nicht gefunden")
|
||||
stored = _load_slots_for_entry(cur, cfg.kind, catalog_id)
|
||||
merged: Dict[str, str] = {}
|
||||
for slot in SLOT_KEYS:
|
||||
if slot == "description":
|
||||
merged[slot] = stored.get("description") or row.get("description") or ""
|
||||
else:
|
||||
merged[slot] = stored.get(slot, "")
|
||||
merged = _resolve_entry_slot_values(stored, row, cfg.kind)
|
||||
return {
|
||||
"catalog_kind": cfg.kind,
|
||||
"catalog_id": int(catalog_id),
|
||||
"name": row["name"],
|
||||
"slots": merged,
|
||||
"stored_slots": {k: stored.get(k, "") for k in SLOT_KEYS},
|
||||
}
|
||||
|
||||
|
||||
@@ -330,15 +341,12 @@ def resolve_catalog_prompt_variables(
|
||||
if not row:
|
||||
continue
|
||||
stored = _load_slots_for_entry(cur, cfg.kind, row["id"]) if _slot_types_table_ready(cur) else {}
|
||||
slot_values: Dict[str, str] = {}
|
||||
slot_values = _resolve_entry_slot_values(stored, row, cfg.kind)
|
||||
for sk in SLOT_KEYS:
|
||||
if sk == "description":
|
||||
slot_values[sk] = stored.get("description") or row.get("description") or ""
|
||||
else:
|
||||
slot_values[sk] = stored.get(sk, "")
|
||||
pk = placeholder_key(cfg.kind, sk)
|
||||
variables[pk] = slot_values[sk]
|
||||
if slot_values[sk].strip() and sk in LLM_SLOT_KEYS:
|
||||
text = slot_values.get(sk, "")
|
||||
variables[pk] = text
|
||||
if text.strip() and sk in LLM_SLOT_KEYS:
|
||||
has_any = True
|
||||
active_slots.append(pk)
|
||||
|
||||
@@ -349,6 +357,7 @@ def resolve_catalog_prompt_variables(
|
||||
"is_primary": bool(active.is_primary),
|
||||
"weight": float(active.weight),
|
||||
"filled_slots": [k for k in LLM_SLOT_KEYS if slot_values.get(k, "").strip()],
|
||||
"stored_slots": [k for k in SLOT_KEYS if (stored.get(k) or "").strip()],
|
||||
}
|
||||
|
||||
section = _render_dimension_section(cfg.label_de, row["name"], slot_values, slot_keys=profile)
|
||||
@@ -379,7 +388,11 @@ def get_rematch_guard_for_catalog(
|
||||
if not active:
|
||||
continue
|
||||
stored = _load_slots_for_entry(cur, cfg.kind, active.id)
|
||||
guard = (stored.get("rematch_guard") or "").strip()
|
||||
row = _load_catalog_row(cur, cfg.table, active.id)
|
||||
if not row:
|
||||
continue
|
||||
slot_values = _resolve_entry_slot_values(stored, row, cfg.kind)
|
||||
guard = (slot_values.get("rematch_guard") or "").strip()
|
||||
if guard:
|
||||
return guard
|
||||
return None
|
||||
|
||||
Reference in new issue
Block a user