enkryptai-sdk 1.0.16__py3-none-any.whl → 1.0.17__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/dto/models.py +12 -19
- enkryptai_sdk/dto/red_team.py +81 -19
- enkryptai_sdk/models.py +2 -0
- enkryptai_sdk/red_team.py +1 -0
- {enkryptai_sdk-1.0.16.dist-info → enkryptai_sdk-1.0.17.dist-info}/METADATA +1 -1
- {enkryptai_sdk-1.0.16.dist-info → enkryptai_sdk-1.0.17.dist-info}/RECORD +9 -9
- {enkryptai_sdk-1.0.16.dist-info → enkryptai_sdk-1.0.17.dist-info}/WHEEL +0 -0
- {enkryptai_sdk-1.0.16.dist-info → enkryptai_sdk-1.0.17.dist-info}/licenses/LICENSE +0 -0
- {enkryptai_sdk-1.0.16.dist-info → enkryptai_sdk-1.0.17.dist-info}/top_level.txt +0 -0
enkryptai_sdk/dto/models.py
CHANGED
|
@@ -5,6 +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
9
|
|
|
9
10
|
|
|
10
11
|
# class Modality(Enum):
|
|
@@ -126,25 +127,6 @@ class OutputModality(str, Enum):
|
|
|
126
127
|
# code = "code"
|
|
127
128
|
|
|
128
129
|
|
|
129
|
-
@dataclass
|
|
130
|
-
class CustomHeader(BaseDTO):
|
|
131
|
-
key: str
|
|
132
|
-
value: str
|
|
133
|
-
|
|
134
|
-
@classmethod
|
|
135
|
-
def from_dict(cls, data: Dict[str, Any]) -> "CustomHeader":
|
|
136
|
-
return cls(
|
|
137
|
-
key=data.get("key", ""),
|
|
138
|
-
value=data.get("value", "")
|
|
139
|
-
)
|
|
140
|
-
|
|
141
|
-
def to_dict(self) -> Dict[str, Any]:
|
|
142
|
-
return {
|
|
143
|
-
"key": self.key,
|
|
144
|
-
"value": self.value
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
|
|
148
130
|
@dataclass
|
|
149
131
|
class ModelConfigDetails(BaseDTO):
|
|
150
132
|
model_id: str = None
|
|
@@ -166,6 +148,8 @@ class ModelConfigDetails(BaseDTO):
|
|
|
166
148
|
apikey: Optional[str] = None
|
|
167
149
|
paths: Optional[PathsConfig] = None
|
|
168
150
|
tools: List[Dict[str, str]] = field(default_factory=list)
|
|
151
|
+
model_auth_type: Optional[ModelAuthTypeEnum] = ModelAuthTypeEnum.APIKEY
|
|
152
|
+
model_jwt_config: Optional[ModelJwtConfig] = None
|
|
169
153
|
auth_data: AuthData = field(default_factory=AuthData)
|
|
170
154
|
input_modalities: List[InputModality] = field(default_factory=list)
|
|
171
155
|
output_modalities: List[OutputModality] = field(default_factory=list)
|
|
@@ -186,6 +170,12 @@ class ModelConfigDetails(BaseDTO):
|
|
|
186
170
|
if "custom_headers" in data:
|
|
187
171
|
data["custom_headers"] = [CustomHeader.from_dict(h) for h in data["custom_headers"]]
|
|
188
172
|
|
|
173
|
+
if "model_auth_type" in data:
|
|
174
|
+
data["model_auth_type"] = ModelAuthTypeEnum(data["model_auth_type"])
|
|
175
|
+
|
|
176
|
+
if "model_jwt_config" in data:
|
|
177
|
+
data["model_jwt_config"] = ModelJwtConfig.from_dict(data["model_jwt_config"])
|
|
178
|
+
|
|
189
179
|
# Convert input_modalities strings to enum values
|
|
190
180
|
if "input_modalities" in data:
|
|
191
181
|
data["input_modalities"] = [InputModality(m) for m in data["input_modalities"]]
|
|
@@ -251,6 +241,9 @@ class ModelConfigDetails(BaseDTO):
|
|
|
251
241
|
|
|
252
242
|
def to_dict(self):
|
|
253
243
|
d = super().to_dict()
|
|
244
|
+
d["model_auth_type"] = self.model_auth_type.value
|
|
245
|
+
if self.model_jwt_config:
|
|
246
|
+
d["model_jwt_config"] = self.model_jwt_config.to_dict()
|
|
254
247
|
# Handle AuthData specifically
|
|
255
248
|
d["auth_data"] = self.auth_data.to_dict()
|
|
256
249
|
# Handle CustomHeader list
|
enkryptai_sdk/dto/red_team.py
CHANGED
|
@@ -20,6 +20,64 @@ class RiskGuardrailDetectorsEnum(str, Enum):
|
|
|
20
20
|
# SYSTEM_PROMPT = "system_prompt"
|
|
21
21
|
|
|
22
22
|
|
|
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
|
+
|
|
23
81
|
@dataclass
|
|
24
82
|
class RedteamHealthResponse(BaseDTO):
|
|
25
83
|
status: str
|
|
@@ -95,6 +153,7 @@ class RedTeamTaskDetails(BaseDTO):
|
|
|
95
153
|
|
|
96
154
|
@classmethod
|
|
97
155
|
def from_dict(cls, data: Dict) -> "RedTeamTaskDetails":
|
|
156
|
+
# print(f"RedTeamTaskDetails data: {data}")
|
|
98
157
|
return cls(
|
|
99
158
|
created_at=data.get("created_at"),
|
|
100
159
|
model_saved_name=data.get("model_saved_name"),
|
|
@@ -368,8 +427,21 @@ class RedTeamTestConfigurations(BaseDTO):
|
|
|
368
427
|
# Advanced tests
|
|
369
428
|
adv_info_test: TestConfig = field(default=None)
|
|
370
429
|
adv_bias_test: TestConfig = field(default=None)
|
|
430
|
+
adv_tool_test: TestConfig = field(default=None)
|
|
371
431
|
adv_command_test: TestConfig = field(default=None)
|
|
432
|
+
adv_pii_test: TestConfig = field(default=None)
|
|
433
|
+
adv_competitor_test: TestConfig = field(default=None)
|
|
434
|
+
# Custom tests
|
|
372
435
|
custom_test: TestConfig = field(default=None)
|
|
436
|
+
# Agents tests
|
|
437
|
+
alignment_and_governance_test: TestConfig = field(default=None)
|
|
438
|
+
input_and_content_integrity_test: TestConfig = field(default=None)
|
|
439
|
+
infrastructure_and_integration_test: TestConfig = field(default=None)
|
|
440
|
+
security_and_privacy_test: TestConfig = field(default=None)
|
|
441
|
+
human_factors_and_societal_impact_test: TestConfig = field(default=None)
|
|
442
|
+
access_control_test: TestConfig = field(default=None)
|
|
443
|
+
physical_and_actuation_safety_test: TestConfig = field(default=None)
|
|
444
|
+
reliability_and_monitoring_test: TestConfig = field(default=None)
|
|
373
445
|
_extra_fields: Dict[str, Any] = field(default_factory=dict)
|
|
374
446
|
|
|
375
447
|
@classmethod
|
|
@@ -391,25 +463,6 @@ class OutputModality(str, Enum):
|
|
|
391
463
|
# audio = "audio"
|
|
392
464
|
# video = "video"
|
|
393
465
|
# code = "code"
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
@dataclass
|
|
397
|
-
class CustomHeader(BaseDTO):
|
|
398
|
-
key: str
|
|
399
|
-
value: str
|
|
400
|
-
|
|
401
|
-
@classmethod
|
|
402
|
-
def from_dict(cls, data: Dict[str, Any]) -> "CustomHeader":
|
|
403
|
-
return cls(
|
|
404
|
-
key=data.get("key", ""),
|
|
405
|
-
value=data.get("value", "")
|
|
406
|
-
)
|
|
407
|
-
|
|
408
|
-
def to_dict(self) -> Dict[str, Any]:
|
|
409
|
-
return {
|
|
410
|
-
"key": self.key,
|
|
411
|
-
"value": self.value
|
|
412
|
-
}
|
|
413
466
|
|
|
414
467
|
|
|
415
468
|
@dataclass
|
|
@@ -422,6 +475,8 @@ class TargetModelConfiguration(BaseDTO):
|
|
|
422
475
|
rate_per_min: int = 20
|
|
423
476
|
model_name: Optional[str] = "gpt-4o-mini"
|
|
424
477
|
model_version: Optional[str] = None
|
|
478
|
+
model_auth_type: Optional[ModelAuthTypeEnum] = ModelAuthTypeEnum.APIKEY
|
|
479
|
+
model_jwt_config: Optional[ModelJwtConfig] = None
|
|
425
480
|
model_api_key: Optional[str] = None
|
|
426
481
|
input_modalities: List[InputModality] = field(default_factory=list)
|
|
427
482
|
output_modalities: List[OutputModality] = field(default_factory=list)
|
|
@@ -437,10 +492,17 @@ class TargetModelConfiguration(BaseDTO):
|
|
|
437
492
|
data = data.copy()
|
|
438
493
|
if "custom_headers" in data:
|
|
439
494
|
data["custom_headers"] = [CustomHeader.from_dict(header) for header in data["custom_headers"]]
|
|
495
|
+
if "model_auth_type" in data:
|
|
496
|
+
data["model_auth_type"] = ModelAuthTypeEnum(data["model_auth_type"])
|
|
497
|
+
if "model_jwt_config" in data:
|
|
498
|
+
data["model_jwt_config"] = ModelJwtConfig.from_dict(data["model_jwt_config"])
|
|
440
499
|
return cls(**data)
|
|
441
500
|
|
|
442
501
|
def to_dict(self) -> dict:
|
|
443
502
|
d = asdict(self)
|
|
503
|
+
d["model_auth_type"] = self.model_auth_type.value
|
|
504
|
+
if self.model_jwt_config:
|
|
505
|
+
d["model_jwt_config"] = self.model_jwt_config.to_dict()
|
|
444
506
|
d["custom_headers"] = [header.to_dict() for header in self.custom_headers]
|
|
445
507
|
return d
|
|
446
508
|
|
enkryptai_sdk/models.py
CHANGED
|
@@ -80,6 +80,8 @@ class ModelClient(BaseClient):
|
|
|
80
80
|
"header_prefix": config.model_config.auth_data.header_prefix,
|
|
81
81
|
"space_after_prefix": config.model_config.auth_data.space_after_prefix,
|
|
82
82
|
},
|
|
83
|
+
"model_auth_type": config.model_config.model_auth_type,
|
|
84
|
+
"model_jwt_config": config.model_config.model_jwt_config,
|
|
83
85
|
"apikeys": [config.model_config.apikey] if config.model_config.apikey else [],
|
|
84
86
|
"tools": config.model_config.tools,
|
|
85
87
|
"input_modalities": [m.value if hasattr(m, 'value') else m for m in config.model_config.input_modalities],
|
enkryptai_sdk/red_team.py
CHANGED
|
@@ -367,6 +367,7 @@ class RedTeamClient(BaseClient):
|
|
|
367
367
|
response = self._request("GET", "/redteam/get-task", headers=headers)
|
|
368
368
|
if response.get("error"):
|
|
369
369
|
raise RedTeamClientError(f"API Error: {str(response)}")
|
|
370
|
+
# print(f"RedTeamTaskDetails response: {response}")
|
|
370
371
|
return RedTeamTaskDetails.from_dict(response["data"])
|
|
371
372
|
|
|
372
373
|
def get_result_summary(self, task_id: str = None, test_name: str = None):
|
|
@@ -8,8 +8,8 @@ enkryptai_sdk/deployments.py,sha256=A7XZ2JwrMod9V4_aV8bFY_Soh9E3jHdwaTuJ9BwXuyk,
|
|
|
8
8
|
enkryptai_sdk/evals.py,sha256=BywyEgIT7xdJ58svO_sDNOMVowdB0RTGoAZPEbCnDVo,2595
|
|
9
9
|
enkryptai_sdk/guardrails.py,sha256=NluimOA0gM9N3S_q47LTUeG97t9PlYqPHlZahDPkJvI,16365
|
|
10
10
|
enkryptai_sdk/guardrails_old.py,sha256=SgzPZkTzbAPD9XfmYNG6M1-TrzbhDHpAkI3FjnVWS_s,6434
|
|
11
|
-
enkryptai_sdk/models.py,sha256=
|
|
12
|
-
enkryptai_sdk/red_team.py,sha256=
|
|
11
|
+
enkryptai_sdk/models.py,sha256=0R0I4KOq0aDNi5utabANot-E8dT9GqiSsgrcI9RULHM,8932
|
|
12
|
+
enkryptai_sdk/red_team.py,sha256=7bWNognd6TCzNQDocml-C_f6u5z1MeursSe3Rtz16Sw,19929
|
|
13
13
|
enkryptai_sdk/response.py,sha256=43JRubzgGCpoVxYNzBZY0AlUgLbfcXD_AwD7wU3qY9o,4086
|
|
14
14
|
enkryptai_sdk/dto/__init__.py,sha256=wHgIv_OCnVMJOys-vqImF59ifogDrMcgxVRmfNayVvc,2761
|
|
15
15
|
enkryptai_sdk/dto/ai_proxy.py,sha256=clwMN4xdH8Zr55dnhilHbs-qaHRlCOrLPrij0Zd1Av0,11283
|
|
@@ -18,10 +18,10 @@ 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
20
|
enkryptai_sdk/dto/guardrails.py,sha256=oJQqFhsdQd_yPU187AhKse-Y4xktgmVNwwKKkzFazbg,50167
|
|
21
|
-
enkryptai_sdk/dto/models.py,sha256=
|
|
22
|
-
enkryptai_sdk/dto/red_team.py,sha256=
|
|
23
|
-
enkryptai_sdk-1.0.
|
|
24
|
-
enkryptai_sdk-1.0.
|
|
25
|
-
enkryptai_sdk-1.0.
|
|
26
|
-
enkryptai_sdk-1.0.
|
|
27
|
-
enkryptai_sdk-1.0.
|
|
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,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|