enkryptai-sdk 0.1.1__py3-none-any.whl → 0.1.2__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- enkryptai_sdk/guardrails.py +15 -15
- {enkryptai_sdk-0.1.1.dist-info → enkryptai_sdk-0.1.2.dist-info}/METADATA +1 -1
- enkryptai_sdk-0.1.2.dist-info/RECORD +9 -0
- enkryptai_sdk-0.1.1.dist-info/RECORD +0 -9
- {enkryptai_sdk-0.1.1.dist-info → enkryptai_sdk-0.1.2.dist-info}/LICENSE +0 -0
- {enkryptai_sdk-0.1.1.dist-info → enkryptai_sdk-0.1.2.dist-info}/WHEEL +0 -0
- {enkryptai_sdk-0.1.1.dist-info → enkryptai_sdk-0.1.2.dist-info}/top_level.txt +0 -0
enkryptai_sdk/guardrails.py
CHANGED
|
@@ -57,7 +57,7 @@ class GuardrailsClient:
|
|
|
57
57
|
"""
|
|
58
58
|
return self._request("GET", "/guardrails/models")
|
|
59
59
|
|
|
60
|
-
def detect(self, text,
|
|
60
|
+
def detect(self, text, config):
|
|
61
61
|
"""
|
|
62
62
|
Detects prompt injection, toxicity, NSFW content, PII, hallucination, and more.
|
|
63
63
|
|
|
@@ -70,12 +70,12 @@ class GuardrailsClient:
|
|
|
70
70
|
- JSON response from the API.
|
|
71
71
|
"""
|
|
72
72
|
# Allow passing in either a dict or a GuardrailsConfig instance.
|
|
73
|
-
if hasattr(
|
|
74
|
-
|
|
73
|
+
if hasattr(config, "as_dict"):
|
|
74
|
+
config = config.as_dict()
|
|
75
75
|
|
|
76
76
|
payload = {
|
|
77
77
|
"text": text,
|
|
78
|
-
"detectors":
|
|
78
|
+
"detectors": config
|
|
79
79
|
}
|
|
80
80
|
return self._request("POST", "/guardrails/detect", json=payload)
|
|
81
81
|
|
|
@@ -94,47 +94,47 @@ class GuardrailsClient:
|
|
|
94
94
|
# Guardrails Policy Endpoints
|
|
95
95
|
# ----------------------------
|
|
96
96
|
|
|
97
|
-
def add_policy(self, name, description,
|
|
97
|
+
def add_policy(self, name, description, config):
|
|
98
98
|
"""
|
|
99
99
|
Create a new policy with custom configurations.
|
|
100
100
|
"""
|
|
101
101
|
payload = {
|
|
102
102
|
"name": name,
|
|
103
103
|
"description": description,
|
|
104
|
-
"detectors":
|
|
104
|
+
"detectors": config
|
|
105
105
|
}
|
|
106
106
|
return self._request("POST", "/guardrails/add-policy", json=payload)
|
|
107
107
|
|
|
108
|
-
def get_policy(self,
|
|
108
|
+
def get_policy(self, policy_name):
|
|
109
109
|
"""
|
|
110
110
|
Retrieve an existing policy by providing its header identifier.
|
|
111
111
|
"""
|
|
112
|
-
headers = {"X-Enkrypt-Policy":
|
|
112
|
+
headers = {"X-Enkrypt-Policy": policy_name}
|
|
113
113
|
return self._request("GET", "/guardrails/get-policy", headers=headers)
|
|
114
114
|
|
|
115
|
-
def modify_policy(self,
|
|
115
|
+
def modify_policy(self, policy_name, name, description, config):
|
|
116
116
|
"""
|
|
117
117
|
Modify an existing policy.
|
|
118
118
|
"""
|
|
119
|
-
headers = {"X-Enkrypt-Policy":
|
|
119
|
+
headers = {"X-Enkrypt-Policy": policy_name}
|
|
120
120
|
payload = {
|
|
121
121
|
"name": name,
|
|
122
122
|
"description": description,
|
|
123
|
-
"detectors":
|
|
123
|
+
"detectors": config
|
|
124
124
|
}
|
|
125
125
|
return self._request("PATCH", "/guardrails/modify-policy", headers=headers, json=payload)
|
|
126
126
|
|
|
127
|
-
def delete_policy(self,
|
|
127
|
+
def delete_policy(self, policy_name):
|
|
128
128
|
"""
|
|
129
129
|
Delete a policy.
|
|
130
130
|
"""
|
|
131
|
-
headers = {"X-Enkrypt-Policy":
|
|
131
|
+
headers = {"X-Enkrypt-Policy": policy_name}
|
|
132
132
|
return self._request("DELETE", "/guardrails/delete-policy", headers=headers)
|
|
133
133
|
|
|
134
|
-
def policy_detect(self,
|
|
134
|
+
def policy_detect(self, policy_name, text):
|
|
135
135
|
"""
|
|
136
136
|
Apply a specific policy to detect and filter content.
|
|
137
137
|
"""
|
|
138
|
-
headers = {"X-Enkrypt-Policy":
|
|
138
|
+
headers = {"X-Enkrypt-Policy": policy_name}
|
|
139
139
|
payload = {"text": text}
|
|
140
140
|
return self._request("POST", "/guardrails/policy/detect", headers=headers, json=payload)
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
enkryptai_sdk/__init__.py,sha256=git4pQzKT36zA-wIDz71crkRhp91FFIYrJXehUcnofg,141
|
|
2
|
+
enkryptai_sdk/guardrails.py,sha256=toEYdYMU0qM6wmrpxfoR-DgzV7tug4NHtilu01CVpP8,4457
|
|
3
|
+
enkryptai_sdk/guardrails_config.py,sha256=oFhCX2hJGVFQfGcaJqji4enc35gK5dTc95uSWungRPE,2487
|
|
4
|
+
enkryptai_sdk/red_team.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
5
|
+
enkryptai_sdk-0.1.2.dist-info/LICENSE,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
6
|
+
enkryptai_sdk-0.1.2.dist-info/METADATA,sha256=rJYlv7XSpSu5O7VzXYFx11--CJIymKM01N2Era_AuO8,2324
|
|
7
|
+
enkryptai_sdk-0.1.2.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
|
|
8
|
+
enkryptai_sdk-0.1.2.dist-info/top_level.txt,sha256=s2X9UJJwvJamNmr6ZXWyyQe60sXtQGWFuaBYfhgHI_4,14
|
|
9
|
+
enkryptai_sdk-0.1.2.dist-info/RECORD,,
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
enkryptai_sdk/__init__.py,sha256=git4pQzKT36zA-wIDz71crkRhp91FFIYrJXehUcnofg,141
|
|
2
|
-
enkryptai_sdk/guardrails.py,sha256=rxUiHPAvdgIjX00XtAY5jPGde-_OEnpmV51jDxAZOSA,4596
|
|
3
|
-
enkryptai_sdk/guardrails_config.py,sha256=oFhCX2hJGVFQfGcaJqji4enc35gK5dTc95uSWungRPE,2487
|
|
4
|
-
enkryptai_sdk/red_team.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
5
|
-
enkryptai_sdk-0.1.1.dist-info/LICENSE,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
6
|
-
enkryptai_sdk-0.1.1.dist-info/METADATA,sha256=DZDuoUjlb5ptOuGdMzTLzkZ561kYqis2VjjhajT3bnE,2324
|
|
7
|
-
enkryptai_sdk-0.1.1.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
|
|
8
|
-
enkryptai_sdk-0.1.1.dist-info/top_level.txt,sha256=s2X9UJJwvJamNmr6ZXWyyQe60sXtQGWFuaBYfhgHI_4,14
|
|
9
|
-
enkryptai_sdk-0.1.1.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|