Skip to content

Commit 86c38e4

Browse files
authored
Merge pull request #25 from m-misiura/guardrails-checks
feat: add `/v1/guardrail/checks` to the server
2 parents 1f3606d + fb8e583 commit 86c38e4

4 files changed

Lines changed: 1152 additions & 11 deletions

File tree

nemoguardrails/rails/llm/llmrails.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -371,7 +371,8 @@ def _prepare_model_kwargs(self, model_config):
371371
Returns:
372372
dict: The prepared kwargs for model initialization
373373
"""
374-
kwargs = model_config.parameters or {}
374+
# Make a copy to avoid modifying the original model config
375+
kwargs = dict(model_config.parameters) if model_config.parameters else {}
375376

376377
# If the optional API Key Environment Variable is set, add it to kwargs
377378
if model_config.api_key_env_var:
@@ -651,7 +652,9 @@ def _get_events_for_messages(self, messages: List[dict], state: Any):
651652
user_message = prev_msg["content"]
652653
break
653654

654-
if user_message:
655+
# If tool input rails are configured, process tool messages even without user message
656+
# This allows standalone tool message validation (e.g., in MCP gateway scenarios)
657+
if user_message or self.config.rails.tool_input.flows:
655658
# If tool input rails are configured, group all tool messages
656659
if self.config.rails.tool_input.flows:
657660
# Collect all tool messages for grouped processing

0 commit comments

Comments
 (0)