Skip to content

Commit 2c0cc90

Browse files
committed
Refactor: move shared constants to utilities/constants.py and update guardrails tests
Signed-off-by: Sandeep20013 <sandeepm20013@gmail.com>
1 parent d98a04a commit 2c0cc90

File tree

5 files changed

+7
-9
lines changed

5 files changed

+7
-9
lines changed

tests/fixtures/guardrails.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
from ocp_resources.resource import ResourceEditor
1414
from ocp_resources.route import Route
1515

16-
from tests.model_explainability.guardrails.constants import HAP_DETECTOR, PROMPT_INJECTION_DETECTOR
16+
from utilities.constants import HAP_DETECTOR, PROMPT_INJECTION_DETECTOR
1717
from utilities.constants import BUILTIN_DETECTOR_CONFIG, Annotations, Labels, VLLMGPUConfig
1818
from utilities.guardrails import check_guardrails_health_endpoint
1919

tests/model_explainability/guardrails/constants.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,7 @@
1212
PII_ENDPOINT: str = "/pii"
1313
AUTOCONFIG_GATEWAY_ENDPOINT: str = "/all"
1414
STANDALONE_DETECTION_ENDPOINT: str = "api/v2/text/detection/content"
15-
PROMPT_INJECTION_DETECTOR: str = "prompt-injection-detector"
16-
HAP_DETECTOR: str = "hap-detector"
15+
1716

1817

1918
@dataclass

tests/model_explainability/guardrails/test_guardrails.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,11 @@
88
AUTOCONFIG_DETECTOR_LABEL,
99
AUTOCONFIG_GATEWAY_ENDPOINT,
1010
CHAT_COMPLETIONS_DETECTION_ENDPOINT,
11-
HAP_DETECTOR,
1211
HAP_INPUT_DETECTION_PROMPT,
1312
HARMLESS_PROMPT,
1413
PII_ENDPOINT,
1514
PII_INPUT_DETECTION_PROMPT,
1615
PII_OUTPUT_DETECTION_PROMPT,
17-
PROMPT_INJECTION_DETECTOR,
1816
PROMPT_INJECTION_INPUT_DETECTION_PROMPT,
1917
STANDALONE_DETECTION_ENDPOINT,
2018
)
@@ -31,7 +29,7 @@
3129
BUILTIN_DETECTOR_CONFIG,
3230
LLM_D_CHAT_GENERATION_CONFIG,
3331
LLMdInferenceSimConfig,
34-
Timeout,
32+
Timeout, PROMPT_INJECTION_DETECTOR, HAP_DETECTOR,
3533
)
3634
from utilities.plugins.constant import OpenAIEnpoints
3735

tests/model_explainability/guardrails/test_guardrails_gpu.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,11 @@
33

44
from tests.model_explainability.guardrails.constants import (
55
CHAT_COMPLETIONS_DETECTION_ENDPOINT,
6-
HAP_DETECTOR,
76
HAP_INPUT_DETECTION_PROMPT,
87
HARMLESS_PROMPT,
98
PII_ENDPOINT,
109
PII_INPUT_DETECTION_PROMPT,
1110
PII_OUTPUT_DETECTION_PROMPT_QWEN,
12-
PROMPT_INJECTION_DETECTOR,
1311
PROMPT_INJECTION_INPUT_DETECTION_PROMPT,
1412
STANDALONE_DETECTION_ENDPOINT,
1513
)
@@ -22,7 +20,7 @@
2220
verify_health_info_response,
2321
)
2422
from utilities.constants import (
25-
VLLMGPUConfig,
23+
VLLMGPUConfig, PROMPT_INJECTION_DETECTOR, HAP_DETECTOR,
2624
)
2725
from utilities.plugins.constant import OpenAIEnpoints
2826

utilities/constants.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -518,3 +518,6 @@ def get_hostname(cls, namespace: str) -> str:
518518

519519
class PodNotFound(Exception):
520520
"""Pod not found"""
521+
522+
PROMPT_INJECTION_DETECTOR: str = "prompt-injection-detector"
523+
HAP_DETECTOR: str = "hap-detector"

0 commit comments

Comments
 (0)