InfoLens / backend /platform /source_page.py
dqy08's picture
重构仓库目录;增加Propagated attribution动画;UI改进
17037b0
Raw
History Blame Contribute Delete
548 Bytes
"""prediction_attribute API 的 source_page slug 规范化(含旧客户端兼容)。"""
ALLOWED_SOURCE_PAGES = frozenset({"analysis", "chat", "attribution", "causal_flow"})
def normalize_source_page(raw: str) -> str | None:
"""剥离 ``.html`` 后缀;``gen_attribute`` → ``causal_flow``;不在白名单则返回 None。"""
s = raw.strip()
if not s:
return None
if s.endswith(".html"):
s = s[:-5]
if s == "gen_attribute":
s = "causal_flow"
return s if s in ALLOWED_SOURCE_PAGES else None