pandas_utils
langroid/utils/pandas_utils.py
UnsafeCommandError
¶
Bases: ValueError
Raised when a command string violates security policy.
CommandValidator(df_name='df')
¶
sanitize_command(expr, df_name='df')
¶
Validate expr; return it unchanged if it passes all rules, else raise UnsafeCommandError with the first violation encountered.
Source code in langroid/utils/pandas_utils.py
safe_eval_globals(local_vars)
¶
Return a globals dict for :func:eval with __builtins__ restricted
to a safe read-only set, so that LLM-generated expressions cannot reach
__import__, eval, exec, open, etc. via Python's implicit
builtin injection.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
local_vars
|
Dict[str, Any]
|
User-provided variables to expose to the eval'd
expression (e.g. |
required |
Returns:
| Type | Description |
|---|---|
Dict[str, Any]
|
A new dict suitable as the |