Skip to content

Instantly share code, notes, and snippets.

@pranjalAI
Last active December 16, 2025 07:03
Show Gist options
  • Select an option

  • Save pranjalAI/03a42b1cad1b32979088244856916b7d to your computer and use it in GitHub Desktop.

Select an option

Save pranjalAI/03a42b1cad1b32979088244856916b7d to your computer and use it in GitHub Desktop.
@dataclass
class NarrativeAgent:
def run(self, state: Dict[str, Any]) -> Dict[str, Any]:
symbol = state["symbol"]
signals = state.get("signals", [])
fired = [s for s in signals if s.get("fired")]
score = len(fired)
if score >= 3:
label = "Needs Review"
elif score == 2:
label = "Moderate"
elif score == 1:
label = "Low"
else:
label = "No Flags Triggered"
# Build a compact explanation list
explanation = []
for s in fired:
explanation.append(f"{s['name']} fired (value={s.get('value')}). {s.get('why')}")
state["risk_summary"] = {
"symbol": symbol,
"risk_label": label,
"signals_fired": score,
"details": explanation,
"note": "This is a screening output based on statement relationships, not a fraud determination."
}
return state
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment