Download guardrails/scope.py from brocode12/wavvy: direct link, hf CLI and curl.
- Browser
- Download file 996 Bytes
-
https://huggingface.co/spaces/brocode12/wavvy/resolve/main/guardrails/scope.py
- Command line
-
hf download hf://spaces/brocode12/wavvy/guardrails/scope.py
-
curl -L -o scope.py https://huggingface.co/spaces/brocode12/wavvy/resolve/main/guardrails/scope.py
996 Bytes
| from dataclasses import dataclass | |
| from typing import Optional | |
| from session.call_session import get_session | |
| FORBIDDEN_ACTIONS: dict[str, list[str]] = { | |
| "voice_agent": [ | |
| "delete_customer", | |
| "access_other_customer", | |
| "view_all_calls", | |
| "generate_refund", | |
| ], | |
| "companion_agent": [ | |
| "execute_crm_write", | |
| "call_any_tool", | |
| ], | |
| "qa_agent": [ | |
| "modify_transcript", | |
| "change_eval_score", | |
| ], | |
| } | |
| class ScopeResult: | |
| allowed: bool | |
| reason: str = "" | |
| inject_message: Optional[str] = None | |
| def check_forbidden_actions(agent_type: str, tool_name: str) -> ScopeResult: | |
| forbidden = FORBIDDEN_ACTIONS.get(agent_type, []) | |
| if tool_name in forbidden: | |
| return ScopeResult( | |
| allowed=False, | |
| reason=f"Tool '{tool_name}' is forbidden for agent type '{agent_type}'", | |
| inject_message="I'm not able to perform that action.", | |
| ) | |
| return ScopeResult(allowed=True) | |