Node two: the auditor
The second node is the audit itself. It takes the transcript and on-screen text, retrieves the rules that bear on them from Azure AI Search, asks GPT-4o to compare the ad against those rules, and writes back a list of violations in a fixed JSON shape.
Last updated: 15 Oct, 2026 · LLMOps
Node one turned the video into text. This node is where the compliance decision is made, and it is a RAG step: retrieve the relevant rules, then generate a judgement grounded in them.
Retrieve, then judge
def audit_content_node(state: VideoAuditState) -> dict:
log.info("auditor node: querying the knowledge base and the LLM")
# the ad's own words become the query against the rules index
ad_content = state["transcript"] + "\n" + state["ocr_text"]
rules = store.similarity_search(ad_content, k=3) # the FTC passages that apply
# the model is asked for the fixed violation shape, not free text
answer = llm.invoke(audit_prompt.format(
rules="\n".join(r.page_content for r in rules),
transcript=state["transcript"],
ocr_text=state["ocr_text"],
))
issues = parse_violations(answer) # -> list of {category, severity, description}
status = "fail" if issues else "pass"
return {"compliance_results": issues, "status": status,
"final_report": format_report(issues)}The model is GPT-4o on Azure, given the retrieved rules and the ad's content, and asked to return violations in the ComplianceIssue shape from the state. Asking for that fixed JSON is the enforcement the TypedDict did not do: the output is parsed into the list the rest of the system expects, and an ad with no violations yields an empty list and a pass.
Why this is the lifecycle in one node
- Retrieval decides what the model sees. If the right rule is not retrieved, the violation is missed, which is the context-recall problem from What to evaluate: RAG vs a plain LLM.
- Faithfulness matters. The verdict has to follow the retrieved rules, not the model's own opinion of the ad.
- Structured output is the contract. A category, a severity and a description per issue is what makes the result something the API can return and a dashboard can count.
Related
- Previous: Node one: indexing the video
- Next: The workflow that wires the nodes
- See also: What to evaluate: RAG vs a plain LLM
- Explain how a missed retrieval and a truly compliant ad produce the same empty result, and how you would tell them apart.
- Name the three fields every violation must carry and why free text would not do.
Little by little, you're building something great.