Skip to content

AI turns documents or topics into real, native PowerPoint decks—with native shapes, transitions and animations, data-backed charts and tables on demand, audio narration from speaker notes, and support for your own .pptx templates. · by Hugo He

feat(chart-recall): add semantic catalog fallback

hugohe39e3603142807
diff --git a/skills/ppt-master/scripts/chart_recall.py b/skills/ppt-master/scripts/chart_recall.py
index 719ee7c4..e084abf1 100644
--- a/skills/ppt-master/scripts/chart_recall.py
+++ b/skills/ppt-master/scripts/chart_recall.py
@@ -161,7 +161,13 @@ def _score_candidate(key: str, summary: str, tags: list[str]) -> tuple[int, list
return score, matched_tags
-def recall_candidates(page: str, tags: list[str], limit: int) -> dict[str, object]:
+def recall_candidates(
+ page: str,
+ tags: list[str],
+ limit: int,
+ *,
+ force_semantic_fallback: bool = False,
+) -> dict[str, object]:
"""Recall a deterministic shortlist for one page."""
charts = load_catalog()
scored: list[tuple[int, str, str, list[str]]] = []
@@ -193,7 +199,7 @@ def recall_candidates(page: str, tags: list[str], limit: int) -> dict[str, objec
else:
confidence = "none"
- return {
+ result: dict[str, object] = {
"page": page,
"semantic_tags": tags,
"confidence": confidence,
@@ -201,9 +207,29 @@ def recall_candidates(page: str, tags: list[str], limit: int) -> dict[str, objec
"no_template_match": {
"allowed": True,
"key": "no-template-match",
- "instruction": "Use when every candidate conflicts with the page content shape or a Skip clause.",
+ "instruction": (
+ "Use only when no catalog rule fits after the applicable lexical and "
+ "semantic review."
+ ),
},
}
+ if confidence in {"low", "none"} or force_semantic_fallback:
+ reason = (
+ "requested-after-candidate-conflict"
+ if force_semantic_fallback
+ else f"lexical-confidence-{confidence}"
+ )
+ result["semantic_fallback"] = {
+ "reason": reason,
+ "instruction": (
+ "Semantically compare the page tags with every returned selection rule. "
+ "Choose one exact catalog key or keep no-template-match; lexical overlap "
+ "is not required in this review."
+ ),
+ "path_pattern": "templates/charts/{key}.svg",
+ "catalog": charts,
+ }
+ return result
def _dedupe(values: list[str]) -> list[str]:
@@ -230,7 +256,12 @@ def _run_recall(args: argparse.Namespace) -> int:
print("Error: recall requires 3-8 distinct non-empty --tag values.", file=sys.stderr)
return 2
- result = recall_candidates(page, tags, args.limit)
+ result = recall_candidates(
+ page,
+ tags,
+ args.limit,
+ force_semantic_fallback=args.semantic_fallback,
+ )
print(json.dumps(result, ensure_ascii=False, indent=2, sort_keys=True))
return 0
@@ -277,6 +308,11 @@ def build_parser() -> argparse.ArgumentParser:
metavar="3..8",
help="Candidate count (default: 6).",
)
+ recall.add_argument(
+ "--semantic-fallback",
+ action="store_true",
+ help="Include the full catalog for AI semantic review after candidate conflict.",
+ )
recall.set_defaults(handler=_run_recall)
validate = subparsers.add_parser("validate", help="Validate selected catalog keys.")