Last active
December 16, 2025 07:03
-
-
Save pranjalAI/03a42b1cad1b32979088244856916b7d to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| @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