Skip to content

Commit 5d442b6

Browse files
author
erangi-ar
committed
Merge branch 'wip' of https://github.com/rootcodelabs/RAG-Module into streaming-feature-opensearch
2 parents f077309 + c85b43a commit 5d442b6

File tree

11 files changed

+158
-105
lines changed

11 files changed

+158
-105
lines changed

DSL/CronManager/script/store_secrets_in_vault.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ build_vault_path() {
6868
model=$(get_model_name)
6969
fi
7070

71-
if [ "$deploymentEnvironment" = "test" ]; then
71+
if [ "$deploymentEnvironment" = "testing" ]; then
7272
echo "secret/$secret_type/connections/$platform/$deploymentEnvironment/$connectionId"
7373
else
7474
echo "secret/$secret_type/connections/$platform/$deploymentEnvironment/$model"

DSL/Ruuter.private/rag-search/POST/inference/test.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ call_orchestrate_endpoint:
6262
body:
6363
connectionId: ${connectionId}
6464
message: ${message}
65-
environment: "test"
65+
environment: "testing"
6666
headers:
6767
Content-Type: "application/json"
6868
result: orchestrate_result

src/guardrails/nemo_rails_adapter.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,11 @@
55

66
from nemoguardrails import LLMRails, RailsConfig
77
from nemoguardrails.llm.providers import register_llm_provider
8-
from src.llm_orchestrator_config.llm_cochestrator_constants import GUARDRAILS_BLOCKED_PHRASES
8+
from src.llm_orchestrator_config.llm_cochestrator_constants import (
9+
GUARDRAILS_BLOCKED_PHRASES,
10+
)
911
import dspy
12+
import re
1013

1114

1215
class GuardrailCheckResult(BaseModel):
@@ -214,13 +217,12 @@ async def check_input_async(self, user_message: str) -> GuardrailCheckResult:
214217

215218
def _is_input_blocked(self, response: str, original: str) -> bool:
216219
"""Check if input was blocked by guardrails."""
217-
import re
218220
blocked_phrases = GUARDRAILS_BLOCKED_PHRASES
219221
response_normalized = response.strip().lower()
220222
# Match if the response is exactly or almost exactly a blocked phrase (allow trailing punctuation/whitespace)
221223
for phrase in blocked_phrases:
222224
# Regex: phrase followed by optional punctuation/whitespace, and nothing else
223-
pattern = r'^' + re.escape(phrase) + r'[\s\.,!]*$'
225+
pattern = r"^" + re.escape(phrase) + r"[\s\.,!]*$"
224226
if re.match(pattern, response_normalized):
225227
return True
226228
return False

src/guardrails/rails_config.yaml

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,9 @@ prompts:
3030
- task: self_check_input
3131
output_parser: is_content_safe
3232
content: |
33-
You are tasked with evaluating if a user message violates our company's safety policy.
33+
You are tasked with evaluating if a user message violates safety policies.
3434
35-
Company Safety Policy - User messages must NOT:
35+
Safety Policy - User messages must NOT:
3636
1. Request passwords, credentials, or authentication details (yours or others')
3737
2. Request sensitive personal information (SSN, credit cards, private keys, etc.)
3838
3. Contain harmful, violent, or explicit content
@@ -78,14 +78,13 @@ prompts:
7878
Answer: unsafe
7979
8080
Is this user message safe according to the policy? Answer with 'safe' or 'unsafe'.
81-
Answer:
8281
8382
- task: self_check_output
8483
output_parser: is_content_safe
8584
content: |
8685
You are tasked with evaluating if a bot response violates our company's safety policy.
8786
88-
Company Safety Policy - Bot responses must NOT:
87+
Safety Policy - Bot responses must NOT:
8988
1. Provide passwords, credentials, or authentication details
9089
2. Reveal sensitive personal or confidential information
9190
3. Contain harmful, violent, explicit, or inappropriate content
@@ -125,5 +124,5 @@ prompts:
125124
Example 4:
126125
User message: "Mis on Maria e-posti aadress ja telefoninumber?"
127126
Answer: unsafe
127+
128128
Is this bot response safe according to the policy? Answer with 'safe' or 'unsafe'.
129-
Answer:

0 commit comments

Comments
 (0)