enkryptai-sdk 1.0.9__py3-none-any.whl → 1.0.10__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/config.py CHANGED
@@ -10,7 +10,7 @@ DEFAULT_GUARDRAILS_CONFIG = {
10
10
  "keyword_detector": {"enabled": False, "banned_keywords": []},
11
11
  "policy_violation": {
12
12
  "enabled": False,
13
- "policy_text": "",
13
+ "policy_text": "Do not allow any illegal or immoral activities.",
14
14
  "need_explanation": False,
15
15
  },
16
16
  "bias": {"enabled": False},
@@ -42,16 +42,21 @@ class GuardrailsConfig:
42
42
  return cls(config)
43
43
 
44
44
  @classmethod
45
- def policy_violation(cls, policy_text: str, need_explanation: bool = False):
45
+ def policy_violation(cls, policy_text: str = "", need_explanation: bool = False, coc_policy_name: str = ""):
46
46
  """
47
47
  Returns a configuration instance pre-configured for policy violation detection.
48
48
  """
49
49
  config = copy.deepcopy(DEFAULT_GUARDRAILS_CONFIG)
50
50
  config["policy_violation"] = {
51
51
  "enabled": True,
52
- "policy_text": policy_text,
53
52
  "need_explanation": need_explanation,
54
53
  }
54
+
55
+ if policy_text:
56
+ config["policy_violation"]["policy_text"] = policy_text
57
+ if coc_policy_name:
58
+ config["policy_violation"]["coc_policy_name"] = coc_policy_name
59
+
55
60
  return cls(config)
56
61
 
57
62
  @classmethod
@@ -163,6 +163,7 @@ class PolicyViolationDetector(BaseDTO):
163
163
  enabled: bool = False
164
164
  policy_text: str = ""
165
165
  need_explanation: bool = False
166
+ coc_policy_name: str = ""
166
167
  _extra_fields: Dict[str, Any] = field(default_factory=dict)
167
168
 
168
169
  @classmethod
@@ -170,16 +171,23 @@ class PolicyViolationDetector(BaseDTO):
170
171
  return cls(
171
172
  enabled=data.get("enabled", False),
172
173
  policy_text=data.get("policy_text", ""),
173
- need_explanation=data.get("need_explanation", False)
174
+ need_explanation=data.get("need_explanation", False),
175
+ coc_policy_name=data.get("coc_policy_name", "")
174
176
  )
175
177
 
176
178
  def to_dict(self) -> Dict[str, Any]:
177
- return {
179
+ res_dict = {
178
180
  "enabled": self.enabled,
179
- "policy_text": self.policy_text,
180
181
  "need_explanation": self.need_explanation
181
182
  }
182
183
 
184
+ if self.policy_text:
185
+ res_dict["policy_text"] = self.policy_text
186
+ if self.coc_policy_name:
187
+ res_dict["coc_policy_name"] = self.coc_policy_name
188
+
189
+ return res_dict
190
+
183
191
 
184
192
  @dataclass
185
193
  class BiasDetector(BaseDTO):
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: enkryptai-sdk
3
- Version: 1.0.9
3
+ Version: 1.0.10
4
4
  Summary: A Python SDK with guardrails and red teaming functionality for API interactions
5
5
  Home-page: https://github.com/enkryptai/enkryptai-sdk
6
6
  Author: Enkrypt AI Team
@@ -264,7 +264,10 @@ sample_detectors = {
264
264
  "policy_violation": {
265
265
  "enabled": True,
266
266
  "need_explanation": True,
267
- "policy_text": ""
267
+ "policy_text": "The model should not provide medical advice when asked about health symptoms."
268
+ # Or we can also give coc_policy_name of a saved Code of Conduct Policy
269
+ # Instead of policy_text
270
+ # "coc_policy_name": "Test CoC Policy"
268
271
  },
269
272
  "bias": {
270
273
  "enabled": False
@@ -718,6 +721,9 @@ guardrails_config = GuardrailsConfig.injection_attack()
718
721
 
719
722
  ```python Python
720
723
  guardrails_config = GuardrailsConfig.policy_violation(policy_text="You must not use hate speech", need_explanation=True)
724
+
725
+ # Or we can also give coc_policy_name of a saved Code of Conduct Policy instead of policy_text
726
+ guardrails_config = GuardrailsConfig.policy_violation(coc_policy_name="Test CoC Policy", need_explanation=True)
721
727
  ```
722
728
 
723
729
  ### [Toxicity](https://docs.enkryptai.com/guardrails-api-reference/Toxicity_Detector)
@@ -2,7 +2,7 @@ enkryptai_sdk/__init__.py,sha256=8H5tznmjirTVdrTmrsyU6fNVRj3-UC0nrTGkzfFp0h0,845
2
2
  enkryptai_sdk/ai_proxy.py,sha256=ot1lqKk2LjcvlpnFm2kSA51vFThfquVlx86BhSbAzBo,3823
3
3
  enkryptai_sdk/base.py,sha256=8iQr5skm46-hGFIMOZsQgZkqL0RBrIJDYUENOybBrwg,3087
4
4
  enkryptai_sdk/coc.py,sha256=5rq9LhZX-uvCmX8fM6JEndIEvd8rSzsSfDFnTvSvTQE,7396
5
- enkryptai_sdk/config.py,sha256=IpB8_aO4zXdvv061v24oh83oyJ5Tp1QBQTzeuW4h9QY,8828
5
+ enkryptai_sdk/config.py,sha256=PyyuJRKWuiuFUaI90M21M141wlfIBeO_QVDU36KHKCs,9065
6
6
  enkryptai_sdk/datasets.py,sha256=RQIR6spI2STXeVolYzBt6gPv6PD5AGh9krs16aKWdWA,6067
7
7
  enkryptai_sdk/deployments.py,sha256=A7XZ2JwrMod9V4_aV8bFY_Soh9E3jHdwaTuJ9BwXuyk,4215
8
8
  enkryptai_sdk/evals.py,sha256=BywyEgIT7xdJ58svO_sDNOMVowdB0RTGoAZPEbCnDVo,2595
@@ -17,11 +17,11 @@ enkryptai_sdk/dto/base.py,sha256=6VWTkoNZ7uILqn_iYsPS21cVa2xLYpw5bjDIsRCS5tk,238
17
17
  enkryptai_sdk/dto/coc.py,sha256=Lp2aat_24J4KuUg4BeJl9S39tEak8Bw15eJ4cQDrRQk,4749
18
18
  enkryptai_sdk/dto/datasets.py,sha256=RFA9CmbhD-QDDyweBq_k9iBd00b6I6SWmdP9DPNd9fc,5002
19
19
  enkryptai_sdk/dto/deployments.py,sha256=Aw4b8tDA3FYIomqDvCjblCXTagL4bT8Fx91X0SFXs40,11216
20
- enkryptai_sdk/dto/guardrails.py,sha256=7hWzhFH-tc6Rbwkl6ZzW_egWTvrLXv4K22M7dNbKQuE,49556
20
+ enkryptai_sdk/dto/guardrails.py,sha256=wfKm2R0uJAq9nljLBPuuT05tj1nBqZraga-5lMHd3n8,49812
21
21
  enkryptai_sdk/dto/models.py,sha256=lNakMstGozgN_htY2_OItkjQnMQpw5tO9lCZVlywMIg,13442
22
22
  enkryptai_sdk/dto/red_team.py,sha256=QtsT4GCnDs24WOF_RMxFtYjvIUULaw5temZ70aduevI,17966
23
- enkryptai_sdk-1.0.9.dist-info/licenses/LICENSE,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
24
- enkryptai_sdk-1.0.9.dist-info/METADATA,sha256=GDQsqPQycozBDIOW3qCfq3wEzNBVPs_4XcmXg-V3kYo,61634
25
- enkryptai_sdk-1.0.9.dist-info/WHEEL,sha256=pxyMxgL8-pra_rKaQ4drOZAegBVuX-G_4nRHjjgWbmo,91
26
- enkryptai_sdk-1.0.9.dist-info/top_level.txt,sha256=s2X9UJJwvJamNmr6ZXWyyQe60sXtQGWFuaBYfhgHI_4,14
27
- enkryptai_sdk-1.0.9.dist-info/RECORD,,
23
+ enkryptai_sdk-1.0.10.dist-info/licenses/LICENSE,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
24
+ enkryptai_sdk-1.0.10.dist-info/METADATA,sha256=elvqsbmZjsswZaBA2cbm1Dmy4teinjb7mR2EPUvtOR0,62092
25
+ enkryptai_sdk-1.0.10.dist-info/WHEEL,sha256=ck4Vq1_RXyvS4Jt6SI0Vz6fyVs4GWg7AINwpsaGEgPE,91
26
+ enkryptai_sdk-1.0.10.dist-info/top_level.txt,sha256=s2X9UJJwvJamNmr6ZXWyyQe60sXtQGWFuaBYfhgHI_4,14
27
+ enkryptai_sdk-1.0.10.dist-info/RECORD,,
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: setuptools (79.0.0)
2
+ Generator: setuptools (80.0.0)
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
5
5