140 lines
4.8 KiB
Python
140 lines
4.8 KiB
Python
|
|
"""
|
||
|
|
Registry: Profil-Stammdaten und statische Zeitraum-Labels für Prompts.
|
||
|
|
"""
|
||
|
|
|
||
|
|
from placeholder_registry import (
|
||
|
|
PlaceholderMetadata,
|
||
|
|
MissingValuePolicy,
|
||
|
|
OutputType,
|
||
|
|
PlaceholderType,
|
||
|
|
register_placeholder,
|
||
|
|
)
|
||
|
|
from ._evidence import tag_standard_evidence
|
||
|
|
|
||
|
|
MVP = lambda reason, disp: MissingValuePolicy(
|
||
|
|
available=False, value_raw=None, missing_reason=reason, legacy_display=disp
|
||
|
|
)
|
||
|
|
|
||
|
|
|
||
|
|
def register_profil_zeitraum():
|
||
|
|
cat_profil = "Profil"
|
||
|
|
for key, desc, res_fn, unit, ptype, out, hint, ex, sem in [
|
||
|
|
(
|
||
|
|
"name",
|
||
|
|
"Anzeigename aus profiles.name",
|
||
|
|
"get_profile_name",
|
||
|
|
"text",
|
||
|
|
PlaceholderType.ATOMIC,
|
||
|
|
OutputType.STRING,
|
||
|
|
"Kurzname",
|
||
|
|
"Max",
|
||
|
|
"profiles.name, Fallback „Nutzer“.",
|
||
|
|
),
|
||
|
|
(
|
||
|
|
"age",
|
||
|
|
"Alter in Jahren aus profiles.dob",
|
||
|
|
"get_profile_age_display",
|
||
|
|
"Jahre",
|
||
|
|
PlaceholderType.ATOMIC,
|
||
|
|
OutputType.STRING,
|
||
|
|
"Ganzzahl oder unbekannt",
|
||
|
|
"42",
|
||
|
|
"Berechnung aus Geburtsdatum; PostgreSQL date oder ISO-String.",
|
||
|
|
),
|
||
|
|
(
|
||
|
|
"height",
|
||
|
|
"Körpergröße (cm) aus profiles.height",
|
||
|
|
"get_profile_height_display",
|
||
|
|
"cm",
|
||
|
|
PlaceholderType.ATOMIC,
|
||
|
|
OutputType.STRING,
|
||
|
|
"Zahl oder unbekannt",
|
||
|
|
"180",
|
||
|
|
"profiles.height.",
|
||
|
|
),
|
||
|
|
(
|
||
|
|
"geschlecht",
|
||
|
|
"Geschlecht (männlich/weiblich) aus profiles.sex",
|
||
|
|
"get_profile_geschlecht_display",
|
||
|
|
"Kategorie",
|
||
|
|
PlaceholderType.ATOMIC,
|
||
|
|
OutputType.STRING,
|
||
|
|
"m/w-Mapping",
|
||
|
|
"männlich",
|
||
|
|
"sex == 'm' → männlich, sonst weiblich.",
|
||
|
|
),
|
||
|
|
]:
|
||
|
|
m = PlaceholderMetadata(
|
||
|
|
key=key,
|
||
|
|
category=cat_profil,
|
||
|
|
description=desc,
|
||
|
|
resolver_module="backend/placeholder_resolver.py",
|
||
|
|
resolver_function=res_fn,
|
||
|
|
data_layer_module=None,
|
||
|
|
data_layer_function=None,
|
||
|
|
source_tables=["profiles"],
|
||
|
|
semantic_contract=sem,
|
||
|
|
business_meaning="Profil-Kontext für KI-Prompts",
|
||
|
|
unit=unit,
|
||
|
|
time_window="latest profile row",
|
||
|
|
output_type=out,
|
||
|
|
placeholder_type=ptype,
|
||
|
|
format_hint=hint,
|
||
|
|
example_output=ex,
|
||
|
|
minimum_data_requirements="Profilzeile",
|
||
|
|
quality_filter_policy=None,
|
||
|
|
confidence_logic="Row vorhanden",
|
||
|
|
missing_value_policy=MVP("no_data", "unbekannt" if key != "name" else "Nutzer"),
|
||
|
|
known_limitations="Keine diversen Geschlechtsoptionen im Platzhalter",
|
||
|
|
layer_1_decision="profiles",
|
||
|
|
layer_2a_decision=res_fn,
|
||
|
|
layer_2b_reuse_possible=False,
|
||
|
|
architecture_alignment="Phase 0b",
|
||
|
|
issue_53_alignment="Resolver",
|
||
|
|
evidence={},
|
||
|
|
)
|
||
|
|
tag_standard_evidence(m)
|
||
|
|
register_placeholder(m)
|
||
|
|
|
||
|
|
cat_zeit = "Zeitraum"
|
||
|
|
for key, desc, res_fn, sem, ex_out in [
|
||
|
|
("datum_heute", "Heutiges Datum (lokal)", "get_datum_heute", "datetime.now, Format dd.mm.yyyy", "11.04.2026"),
|
||
|
|
("zeitraum_7d", "Label „letzte 7 Tage“", "get_zeitraum_label_7d", "Statisches UI/Prompt-Label", "letzte 7 Tage"),
|
||
|
|
("zeitraum_30d", "Label „letzte 30 Tage“", "get_zeitraum_label_30d", "Statisches UI/Prompt-Label", "letzte 30 Tage"),
|
||
|
|
("zeitraum_90d", "Label „letzte 90 Tage“", "get_zeitraum_label_90d", "Statisches UI/Prompt-Label", "letzte 90 Tage"),
|
||
|
|
]:
|
||
|
|
m = PlaceholderMetadata(
|
||
|
|
key=key,
|
||
|
|
category=cat_zeit,
|
||
|
|
description=desc,
|
||
|
|
resolver_module="backend/placeholder_resolver.py",
|
||
|
|
resolver_function=res_fn,
|
||
|
|
data_layer_module=None,
|
||
|
|
data_layer_function=None,
|
||
|
|
source_tables=[],
|
||
|
|
semantic_contract=sem,
|
||
|
|
business_meaning="Zeitlicher Bezug im Prompt ohne Datenabfrage",
|
||
|
|
unit="label",
|
||
|
|
time_window="n/a",
|
||
|
|
output_type=OutputType.STRING,
|
||
|
|
placeholder_type=PlaceholderType.META,
|
||
|
|
format_hint="Kurzdeutsch",
|
||
|
|
example_output=ex_out,
|
||
|
|
minimum_data_requirements=None,
|
||
|
|
quality_filter_policy=None,
|
||
|
|
confidence_logic="Immer verfügbar",
|
||
|
|
missing_value_policy=None,
|
||
|
|
known_limitations="Kein kalender-basierter Datenfilter allein durch Platzhalter",
|
||
|
|
layer_1_decision="n/a",
|
||
|
|
layer_2a_decision=res_fn,
|
||
|
|
layer_2b_reuse_possible=False,
|
||
|
|
architecture_alignment="Phase 0b",
|
||
|
|
issue_53_alignment="Resolver",
|
||
|
|
evidence={},
|
||
|
|
)
|
||
|
|
tag_standard_evidence(m)
|
||
|
|
register_placeholder(m)
|
||
|
|
|
||
|
|
|
||
|
|
register_profil_zeitraum()
|