feat(asr-pipeline): merge PR #1 webauth/CSRF/locking hardening and web_password fallback
This commit is contained in:
@@ -337,6 +337,18 @@ def normalize_chunks(chunks, cleaned_parts: list[str], flags: list[dict],
|
||||
}
|
||||
|
||||
|
||||
def scrub_internal_wording(text: str) -> str:
|
||||
"""Keep pipeline jargon out of text a person will read."""
|
||||
for src, dst in (
|
||||
("卡片未提供", "记录未写明"),
|
||||
("卡片提及", "录音中提到"),
|
||||
("事实卡片", "整理要点"),
|
||||
("粗整理草稿", "整理稿"),
|
||||
):
|
||||
text = text.replace(src, dst)
|
||||
return text
|
||||
|
||||
|
||||
def extract_evidence(parts: list[str], usage: Usage) -> str:
|
||||
jobs = [prompts.EVIDENCE_PROMPT.format(chunk_id=i, body=body)
|
||||
for i, body in enumerate(parts)]
|
||||
@@ -347,7 +359,7 @@ def extract_evidence(parts: list[str], usage: Usage) -> str:
|
||||
max_tokens=1400, usage=usage)
|
||||
except PartialFailure as pf:
|
||||
outs = pf.outputs
|
||||
return "\n".join(x for x in outs if x.strip())
|
||||
return scrub_internal_wording("\n".join(x for x in outs if x.strip()))
|
||||
|
||||
|
||||
# ------------------------------------------------------------------ S4
|
||||
@@ -386,7 +398,7 @@ def write_draft(cleaned: str, meta: dict, context: str, date: str,
|
||||
speaker_note=prompts.SPEAKER_NOTE.get(backend, ""),
|
||||
context=ctx, date=date, source_detail=detail,
|
||||
transcript=transcript_path, extra_fm=extra, body=cleaned)
|
||||
return chat(CFG.draft_model, prompt, max_tokens=12000, usage=usage)
|
||||
return scrub_internal_wording(chat(CFG.draft_model, prompt, max_tokens=12000, usage=usage))
|
||||
|
||||
|
||||
# ------------------------------------------------------------------ driver
|
||||
|
||||
Reference in New Issue
Block a user