enkryptai-sdk 1.0.9__tar.gz → 1.0.10__tar.gz

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.
Files changed (45) hide show
  1. {enkryptai_sdk-1.0.9/src/enkryptai_sdk.egg-info → enkryptai_sdk-1.0.10}/PKG-INFO +8 -2
  2. {enkryptai_sdk-1.0.9 → enkryptai_sdk-1.0.10}/README.md +7 -1
  3. {enkryptai_sdk-1.0.9 → enkryptai_sdk-1.0.10}/setup.py +1 -1
  4. {enkryptai_sdk-1.0.9 → enkryptai_sdk-1.0.10}/src/enkryptai_sdk/config.py +8 -3
  5. {enkryptai_sdk-1.0.9 → enkryptai_sdk-1.0.10}/src/enkryptai_sdk/dto/guardrails.py +11 -3
  6. {enkryptai_sdk-1.0.9 → enkryptai_sdk-1.0.10/src/enkryptai_sdk.egg-info}/PKG-INFO +8 -2
  7. {enkryptai_sdk-1.0.9 → enkryptai_sdk-1.0.10}/tests/test_all_v2.py +1 -1
  8. {enkryptai_sdk-1.0.9 → enkryptai_sdk-1.0.10}/tests/test_guardrails.py +1 -1
  9. {enkryptai_sdk-1.0.9 → enkryptai_sdk-1.0.10}/LICENSE +0 -0
  10. {enkryptai_sdk-1.0.9 → enkryptai_sdk-1.0.10}/setup.cfg +0 -0
  11. {enkryptai_sdk-1.0.9 → enkryptai_sdk-1.0.10}/src/enkryptai_sdk/__init__.py +0 -0
  12. {enkryptai_sdk-1.0.9 → enkryptai_sdk-1.0.10}/src/enkryptai_sdk/ai_proxy.py +0 -0
  13. {enkryptai_sdk-1.0.9 → enkryptai_sdk-1.0.10}/src/enkryptai_sdk/base.py +0 -0
  14. {enkryptai_sdk-1.0.9 → enkryptai_sdk-1.0.10}/src/enkryptai_sdk/coc.py +0 -0
  15. {enkryptai_sdk-1.0.9 → enkryptai_sdk-1.0.10}/src/enkryptai_sdk/datasets.py +0 -0
  16. {enkryptai_sdk-1.0.9 → enkryptai_sdk-1.0.10}/src/enkryptai_sdk/deployments.py +0 -0
  17. {enkryptai_sdk-1.0.9 → enkryptai_sdk-1.0.10}/src/enkryptai_sdk/dto/__init__.py +0 -0
  18. {enkryptai_sdk-1.0.9 → enkryptai_sdk-1.0.10}/src/enkryptai_sdk/dto/ai_proxy.py +0 -0
  19. {enkryptai_sdk-1.0.9 → enkryptai_sdk-1.0.10}/src/enkryptai_sdk/dto/base.py +0 -0
  20. {enkryptai_sdk-1.0.9 → enkryptai_sdk-1.0.10}/src/enkryptai_sdk/dto/coc.py +0 -0
  21. {enkryptai_sdk-1.0.9 → enkryptai_sdk-1.0.10}/src/enkryptai_sdk/dto/datasets.py +0 -0
  22. {enkryptai_sdk-1.0.9 → enkryptai_sdk-1.0.10}/src/enkryptai_sdk/dto/deployments.py +0 -0
  23. {enkryptai_sdk-1.0.9 → enkryptai_sdk-1.0.10}/src/enkryptai_sdk/dto/models.py +0 -0
  24. {enkryptai_sdk-1.0.9 → enkryptai_sdk-1.0.10}/src/enkryptai_sdk/dto/red_team.py +0 -0
  25. {enkryptai_sdk-1.0.9 → enkryptai_sdk-1.0.10}/src/enkryptai_sdk/evals.py +0 -0
  26. {enkryptai_sdk-1.0.9 → enkryptai_sdk-1.0.10}/src/enkryptai_sdk/guardrails.py +0 -0
  27. {enkryptai_sdk-1.0.9 → enkryptai_sdk-1.0.10}/src/enkryptai_sdk/guardrails_old.py +0 -0
  28. {enkryptai_sdk-1.0.9 → enkryptai_sdk-1.0.10}/src/enkryptai_sdk/models.py +0 -0
  29. {enkryptai_sdk-1.0.9 → enkryptai_sdk-1.0.10}/src/enkryptai_sdk/red_team.py +0 -0
  30. {enkryptai_sdk-1.0.9 → enkryptai_sdk-1.0.10}/src/enkryptai_sdk/response.py +0 -0
  31. {enkryptai_sdk-1.0.9 → enkryptai_sdk-1.0.10}/src/enkryptai_sdk.egg-info/SOURCES.txt +0 -0
  32. {enkryptai_sdk-1.0.9 → enkryptai_sdk-1.0.10}/src/enkryptai_sdk.egg-info/dependency_links.txt +0 -0
  33. {enkryptai_sdk-1.0.9 → enkryptai_sdk-1.0.10}/src/enkryptai_sdk.egg-info/top_level.txt +0 -0
  34. {enkryptai_sdk-1.0.9 → enkryptai_sdk-1.0.10}/tests/test_ai_proxy.py +0 -0
  35. {enkryptai_sdk-1.0.9 → enkryptai_sdk-1.0.10}/tests/test_all.py +0 -0
  36. {enkryptai_sdk-1.0.9 → enkryptai_sdk-1.0.10}/tests/test_basic.py +0 -0
  37. {enkryptai_sdk-1.0.9 → enkryptai_sdk-1.0.10}/tests/test_coc.py +0 -0
  38. {enkryptai_sdk-1.0.9 → enkryptai_sdk-1.0.10}/tests/test_datasets.py +0 -0
  39. {enkryptai_sdk-1.0.9 → enkryptai_sdk-1.0.10}/tests/test_deployments.py +0 -0
  40. {enkryptai_sdk-1.0.9 → enkryptai_sdk-1.0.10}/tests/test_detect_policy.py +0 -0
  41. {enkryptai_sdk-1.0.9 → enkryptai_sdk-1.0.10}/tests/test_injection_attack.py +0 -0
  42. {enkryptai_sdk-1.0.9 → enkryptai_sdk-1.0.10}/tests/test_model.py +0 -0
  43. {enkryptai_sdk-1.0.9 → enkryptai_sdk-1.0.10}/tests/test_openai.py +0 -0
  44. {enkryptai_sdk-1.0.9 → enkryptai_sdk-1.0.10}/tests/test_policy_violation.py +0 -0
  45. {enkryptai_sdk-1.0.9 → enkryptai_sdk-1.0.10}/tests/test_redteam.py +0 -0
@@ -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)
@@ -241,7 +241,10 @@ sample_detectors = {
241
241
  "policy_violation": {
242
242
  "enabled": True,
243
243
  "need_explanation": True,
244
- "policy_text": ""
244
+ "policy_text": "The model should not provide medical advice when asked about health symptoms."
245
+ # Or we can also give coc_policy_name of a saved Code of Conduct Policy
246
+ # Instead of policy_text
247
+ # "coc_policy_name": "Test CoC Policy"
245
248
  },
246
249
  "bias": {
247
250
  "enabled": False
@@ -695,6 +698,9 @@ guardrails_config = GuardrailsConfig.injection_attack()
695
698
 
696
699
  ```python Python
697
700
  guardrails_config = GuardrailsConfig.policy_violation(policy_text="You must not use hate speech", need_explanation=True)
701
+
702
+ # Or we can also give coc_policy_name of a saved Code of Conduct Policy instead of policy_text
703
+ guardrails_config = GuardrailsConfig.policy_violation(coc_policy_name="Test CoC Policy", need_explanation=True)
698
704
  ```
699
705
 
700
706
  ### [Toxicity](https://docs.enkryptai.com/guardrails-api-reference/Toxicity_Detector)
@@ -9,7 +9,7 @@ with open(os.path.join(here, "README.md"), encoding="utf-8") as fh:
9
9
  setup(
10
10
  name="enkryptai-sdk", # This is the name of your package on PyPI
11
11
  # NOTE: Also change this in .github/workflows/test.yaml
12
- version="1.0.9", # Update this for new versions
12
+ version="1.0.10", # Update this for new versions
13
13
  description="A Python SDK with guardrails and red teaming functionality for API interactions",
14
14
  long_description=long_description,
15
15
  long_description_content_type="text/markdown",
@@ -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)
@@ -141,7 +141,7 @@ def sample_detectors():
141
141
  "policy_violation": {
142
142
  "enabled": True,
143
143
  "need_explanation": True,
144
- "policy_text": ""
144
+ "policy_text": "Do not allow any illegal or immoral activities."
145
145
  },
146
146
  "bias": {
147
147
  "enabled": False
@@ -63,7 +63,7 @@ def sample_detectors():
63
63
  "policy_violation": {
64
64
  "enabled": True,
65
65
  "need_explanation": True,
66
- "policy_text": ""
66
+ "policy_text": "Do not allow any illegal or immoral activities."
67
67
  },
68
68
  "bias": {
69
69
  "enabled": False
File without changes
File without changes