enkryptai-sdk 1.0.17__py3-none-any.whl → 1.0.18__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.
@@ -0,0 +1,64 @@
1
+ # To avoid circular imports
2
+ from enum import Enum
3
+ from .base import BaseDTO
4
+ from typing import Dict, List, Optional, Any
5
+ from dataclasses import dataclass, field, asdict
6
+
7
+
8
+ class ModelAuthTypeEnum(str, Enum):
9
+ APIKEY = "apikey"
10
+ JWT = "jwt"
11
+
12
+
13
+ class ModelJwtMethodEnum(str, Enum):
14
+ POST = "POST"
15
+ GET = "GET"
16
+
17
+
18
+ @dataclass
19
+ class CustomHeader(BaseDTO):
20
+ key: str
21
+ value: str
22
+
23
+ @classmethod
24
+ def from_dict(cls, data: Dict[str, Any]) -> "CustomHeader":
25
+ return cls(
26
+ key=data.get("key", ""),
27
+ value=data.get("value", "")
28
+ )
29
+
30
+ def to_dict(self) -> Dict[str, Any]:
31
+ return {
32
+ "key": self.key,
33
+ "value": self.value
34
+ }
35
+
36
+
37
+ @dataclass
38
+ class ModelJwtConfig(BaseDTO):
39
+ jwt_method: ModelJwtMethodEnum = ModelJwtMethodEnum.POST
40
+ jwt_url: str = ""
41
+ jwt_headers: List[CustomHeader] = field(default_factory=list)
42
+ jwt_body: str = ""
43
+ jwt_response_key: str = ""
44
+ _extra_fields: Dict[str, Any] = field(default_factory=dict)
45
+
46
+ @classmethod
47
+ def from_dict(cls, data: Dict[str, Any]) -> "ModelJwtConfig":
48
+ return cls(
49
+ jwt_method=ModelJwtMethodEnum(data.get("jwt_method", ModelJwtMethodEnum.POST)),
50
+ jwt_url=data.get("jwt_url", ""),
51
+ jwt_headers=[CustomHeader.from_dict(header) for header in data.get("jwt_headers", [])],
52
+ jwt_body=data.get("jwt_body", ""),
53
+ jwt_response_key=data.get("jwt_response_key", ""),
54
+ )
55
+
56
+ def to_dict(self) -> Dict[str, Any]:
57
+ return {
58
+ "jwt_method": self.jwt_method.value,
59
+ "jwt_url": self.jwt_url,
60
+ "jwt_headers": [header.to_dict() for header in self.jwt_headers],
61
+ "jwt_body": self.jwt_body,
62
+ "jwt_response_key": self.jwt_response_key,
63
+ }
64
+
@@ -5,7 +5,7 @@ from .base import BaseDTO
5
5
  from tabulate import tabulate
6
6
  from dataclasses import dataclass, field, asdict
7
7
  from typing import Optional, List, Set, Dict, Any
8
- from .red_team import ModelAuthTypeEnum, CustomHeader, ModelJwtConfig
8
+ from .common import ModelAuthTypeEnum, CustomHeader, ModelJwtConfig
9
9
 
10
10
 
11
11
  # class Modality(Enum):
@@ -3,9 +3,11 @@ from enum import Enum
3
3
  from .base import BaseDTO
4
4
  from typing import Dict, List, Optional, Any
5
5
  from dataclasses import dataclass, field, asdict
6
+
6
7
  from .datasets import DatasetConfig
7
8
  from .models import ModelConfig
8
9
  from .guardrails import GuardrailDetectors
10
+ from .common import ModelAuthTypeEnum, CustomHeader, ModelJwtConfig
9
11
 
10
12
  # The risk mitigation do not support all detectors, so we need to create a separate enum for them.
11
13
  class RiskGuardrailDetectorsEnum(str, Enum):
@@ -20,64 +22,6 @@ class RiskGuardrailDetectorsEnum(str, Enum):
20
22
  # SYSTEM_PROMPT = "system_prompt"
21
23
 
22
24
 
23
- class ModelAuthTypeEnum(str, Enum):
24
- APIKEY = "apikey"
25
- JWT = "jwt"
26
-
27
-
28
- class ModelJwtMethodEnum(str, Enum):
29
- POST = "POST"
30
- GET = "GET"
31
-
32
-
33
- @dataclass
34
- class CustomHeader(BaseDTO):
35
- key: str
36
- value: str
37
-
38
- @classmethod
39
- def from_dict(cls, data: Dict[str, Any]) -> "CustomHeader":
40
- return cls(
41
- key=data.get("key", ""),
42
- value=data.get("value", "")
43
- )
44
-
45
- def to_dict(self) -> Dict[str, Any]:
46
- return {
47
- "key": self.key,
48
- "value": self.value
49
- }
50
-
51
-
52
- @dataclass
53
- class ModelJwtConfig(BaseDTO):
54
- jwt_method: ModelJwtMethodEnum = ModelJwtMethodEnum.POST
55
- jwt_url: str = ""
56
- jwt_headers: List[CustomHeader] = field(default_factory=list)
57
- jwt_body: str = ""
58
- jwt_response_key: str = ""
59
- _extra_fields: Dict[str, Any] = field(default_factory=dict)
60
-
61
- @classmethod
62
- def from_dict(cls, data: Dict[str, Any]) -> "ModelJwtConfig":
63
- return cls(
64
- jwt_method=ModelJwtMethodEnum(data.get("jwt_method", ModelJwtMethodEnum.POST)),
65
- jwt_url=data.get("jwt_url", ""),
66
- jwt_headers=[CustomHeader.from_dict(header) for header in data.get("jwt_headers", [])],
67
- jwt_body=data.get("jwt_body", ""),
68
- jwt_response_key=data.get("jwt_response_key", ""),
69
- )
70
-
71
- def to_dict(self) -> Dict[str, Any]:
72
- return {
73
- "jwt_method": self.jwt_method.value,
74
- "jwt_url": self.jwt_url,
75
- "jwt_headers": [header.to_dict() for header in self.jwt_headers],
76
- "jwt_body": self.jwt_body,
77
- "jwt_response_key": self.jwt_response_key,
78
- }
79
-
80
-
81
25
  @dataclass
82
26
  class RedteamHealthResponse(BaseDTO):
83
27
  status: str
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: enkryptai-sdk
3
- Version: 1.0.17
3
+ Version: 1.0.18
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
@@ -15,13 +15,14 @@ enkryptai_sdk/dto/__init__.py,sha256=wHgIv_OCnVMJOys-vqImF59ifogDrMcgxVRmfNayVvc
15
15
  enkryptai_sdk/dto/ai_proxy.py,sha256=clwMN4xdH8Zr55dnhilHbs-qaHRlCOrLPrij0Zd1Av0,11283
16
16
  enkryptai_sdk/dto/base.py,sha256=y77kQL1X7389ifSVNc0E7CUFNxACh5AM3ml9YPon1KY,2822
17
17
  enkryptai_sdk/dto/coc.py,sha256=Lp2aat_24J4KuUg4BeJl9S39tEak8Bw15eJ4cQDrRQk,4749
18
+ enkryptai_sdk/dto/common.py,sha256=lrWMu4FKUGCN2dbS9fT4yNtfiPm1cNN16J4eCe4_tBM,1812
18
19
  enkryptai_sdk/dto/datasets.py,sha256=RFA9CmbhD-QDDyweBq_k9iBd00b6I6SWmdP9DPNd9fc,5002
19
20
  enkryptai_sdk/dto/deployments.py,sha256=Aw4b8tDA3FYIomqDvCjblCXTagL4bT8Fx91X0SFXs40,11216
20
21
  enkryptai_sdk/dto/guardrails.py,sha256=oJQqFhsdQd_yPU187AhKse-Y4xktgmVNwwKKkzFazbg,50167
21
- enkryptai_sdk/dto/models.py,sha256=Nk6ZQyMfDMbl5ITQWQJUZMPxQOTATA65QbKHIy7i3qM,14533
22
- enkryptai_sdk/dto/red_team.py,sha256=NrYj9NZX3EmrBpESiZYFUCzgXH3eConh4NhVRKT28LM,27362
23
- enkryptai_sdk-1.0.17.dist-info/licenses/LICENSE,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
24
- enkryptai_sdk-1.0.17.dist-info/METADATA,sha256=10vTRJNUYuEu7KgixIMOvgaweistehy8_s3kf3lkXiA,72860
25
- enkryptai_sdk-1.0.17.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
26
- enkryptai_sdk-1.0.17.dist-info/top_level.txt,sha256=s2X9UJJwvJamNmr6ZXWyyQe60sXtQGWFuaBYfhgHI_4,14
27
- enkryptai_sdk-1.0.17.dist-info/RECORD,,
22
+ enkryptai_sdk/dto/models.py,sha256=4aeI9-iHPhSX5duRMTQRbkXhplAhN8OHw3gWdTxrafU,14531
23
+ enkryptai_sdk/dto/red_team.py,sha256=BAvjpz_Xxb4UW5GRmvfOLV3KvvciPyVGUyYgNDBzq2E,25790
24
+ enkryptai_sdk-1.0.18.dist-info/licenses/LICENSE,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
25
+ enkryptai_sdk-1.0.18.dist-info/METADATA,sha256=PWAkBaJJiqgxvUfRfSbO9wUSNaYsAczTiFwB8sycVo0,72860
26
+ enkryptai_sdk-1.0.18.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
27
+ enkryptai_sdk-1.0.18.dist-info/top_level.txt,sha256=s2X9UJJwvJamNmr6ZXWyyQe60sXtQGWFuaBYfhgHI_4,14
28
+ enkryptai_sdk-1.0.18.dist-info/RECORD,,