Skip to content

enrich_lineage_steps_with_ai

Public callable

Optionally enrich deterministic lineage steps using an AI helper callable.

Parameters:

Name Type Description Default
lineage_steps list of dict of str to Any

Deterministic lineage step dictionaries.

required
ai_helper Any or None

Callable that accepts lineage steps and returns enriched steps.

None

Returns:

Type Description
dict of str to Any

Enrichment payload containing steps, AI usage flag, fallback prompt, and notes.

Source code in src/fabricops_kit/lineage.py
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
def enrich_lineage_steps_with_ai(lineage_steps: list[dict[str, Any]], ai_helper: Any | None = None) -> dict[str, Any]:
    """Optionally enrich deterministic lineage steps using an AI helper callable.

    Parameters
    ----------
    lineage_steps : list of dict of str to Any
        Deterministic lineage step dictionaries.
    ai_helper : Any or None, default=None
        Callable that accepts lineage steps and returns enriched steps.

    Returns
    -------
    dict of str to Any
        Enrichment payload containing steps, AI usage flag, fallback prompt, and notes.
    """
    if ai_helper is None:
        return {"steps": lineage_steps, "ai_used": False, "fallback_prompt": fallback_copilot_lineage_prompt(lineage_steps), "notes": "AI helper unavailable; Copilot fallback prompt generated."}
    return {"steps": ai_helper(lineage_steps) or lineage_steps, "ai_used": True, "fallback_prompt": "", "notes": "AI enrichment applied."}