enkryptai-sdk 1.0.2__py3-none-any.whl → 1.0.4__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/ai_proxy.py +6 -4
- enkryptai_sdk/evals.py +3 -3
- enkryptai_sdk/models.py +1 -1
- enkryptai_sdk/red_team.py +2 -2
- {enkryptai_sdk-1.0.2.dist-info → enkryptai_sdk-1.0.4.dist-info}/METADATA +1 -1
- {enkryptai_sdk-1.0.2.dist-info → enkryptai_sdk-1.0.4.dist-info}/RECORD +9 -9
- {enkryptai_sdk-1.0.2.dist-info → enkryptai_sdk-1.0.4.dist-info}/WHEEL +0 -0
- {enkryptai_sdk-1.0.2.dist-info → enkryptai_sdk-1.0.4.dist-info}/licenses/LICENSE +0 -0
- {enkryptai_sdk-1.0.2.dist-info → enkryptai_sdk-1.0.4.dist-info}/top_level.txt +0 -0
enkryptai_sdk/ai_proxy.py
CHANGED
|
@@ -54,7 +54,7 @@ class AIProxyClient(BaseClient):
|
|
|
54
54
|
# Try to parse nested JSON error if it's a string
|
|
55
55
|
if isinstance(error_message, str) and is_json_str:
|
|
56
56
|
import ast
|
|
57
|
-
import json
|
|
57
|
+
# import json
|
|
58
58
|
try:
|
|
59
59
|
# # Using ast.literal_eval to safely evaluate the string as a Python literal
|
|
60
60
|
# # As json.loads is not working with literal string representation of dict
|
|
@@ -65,7 +65,8 @@ class AIProxyClient(BaseClient):
|
|
|
65
65
|
response["error"] = parsed_error.get("error", parsed_error)
|
|
66
66
|
if "enkrypt_policy_detections" in parsed_error:
|
|
67
67
|
response["enkrypt_policy_detections"] = parsed_error["enkrypt_policy_detections"]
|
|
68
|
-
except json.JSONDecodeError:
|
|
68
|
+
# except json.JSONDecodeError:
|
|
69
|
+
except Exception:
|
|
69
70
|
# If parsing fails, keep the original error
|
|
70
71
|
pass
|
|
71
72
|
|
|
@@ -78,9 +79,10 @@ class AIProxyClient(BaseClient):
|
|
|
78
79
|
try:
|
|
79
80
|
# print("Error in response: ", response)
|
|
80
81
|
return ChatCompletionErrorResponse.from_dict(response)
|
|
81
|
-
except (json.JSONDecodeError, TypeError, ValueError, SyntaxError):
|
|
82
|
+
# except (json.JSONDecodeError, TypeError, ValueError, SyntaxError):
|
|
83
|
+
except Exception:
|
|
82
84
|
# Fallback to direct error if error object can't be parsed
|
|
83
|
-
print("Failed to parse error response: ", response)
|
|
85
|
+
# print("Failed to parse error response: ", response)
|
|
84
86
|
return ChatCompletionDirectErrorResponse.from_dict(response)
|
|
85
87
|
raise AIProxyClientError(response["error"])
|
|
86
88
|
|
enkryptai_sdk/evals.py
CHANGED
|
@@ -34,7 +34,7 @@ class EvalsClient:
|
|
|
34
34
|
return response.json()
|
|
35
35
|
|
|
36
36
|
except Exception as e:
|
|
37
|
-
print(e)
|
|
37
|
+
# print(e)
|
|
38
38
|
return {"error": str(e)}
|
|
39
39
|
|
|
40
40
|
# ----------------------------
|
|
@@ -59,7 +59,7 @@ class EvalsClient:
|
|
|
59
59
|
try:
|
|
60
60
|
return self._request("POST", "/guardrails/adherence", json=payload)
|
|
61
61
|
except Exception as e:
|
|
62
|
-
print(e)
|
|
62
|
+
# print(e)
|
|
63
63
|
return {"error": str(e)}
|
|
64
64
|
|
|
65
65
|
def check_relevancy(self, question, llm_answer):
|
|
@@ -80,5 +80,5 @@ class EvalsClient:
|
|
|
80
80
|
try:
|
|
81
81
|
return self._request("POST", "/guardrails/relevancy", json=payload)
|
|
82
82
|
except Exception as e:
|
|
83
|
-
print(e)
|
|
83
|
+
# print(e)
|
|
84
84
|
return {"error": str(e)}
|
enkryptai_sdk/models.py
CHANGED
|
@@ -103,7 +103,7 @@ class ModelClient(BaseClient):
|
|
|
103
103
|
"""
|
|
104
104
|
headers = {"X-Enkrypt-Model": model_saved_name}
|
|
105
105
|
response = self._request("GET", "/models/get-model", headers=headers)
|
|
106
|
-
print(response)
|
|
106
|
+
# print(response)
|
|
107
107
|
if response.get("error"):
|
|
108
108
|
raise ModelClientError(response["error"])
|
|
109
109
|
return ModelConfig.from_dict(response)
|
enkryptai_sdk/red_team.py
CHANGED
|
@@ -275,7 +275,7 @@ class RedTeamClient(BaseClient):
|
|
|
275
275
|
response = self._request("GET", "/redteam/results/summary", headers=headers)
|
|
276
276
|
if response.get("error"):
|
|
277
277
|
raise RedTeamClientError(response["error"])
|
|
278
|
-
print(f"Response: {response}")
|
|
278
|
+
# print(f"Response: {response}")
|
|
279
279
|
return RedTeamResultSummary.from_dict(response)
|
|
280
280
|
|
|
281
281
|
def get_result_summary_test_type(self, task_id: str = None, test_name: str = None, test_type: str = None):
|
|
@@ -309,7 +309,7 @@ class RedTeamClient(BaseClient):
|
|
|
309
309
|
response = self._request("GET", url, headers=headers)
|
|
310
310
|
if response.get("error"):
|
|
311
311
|
raise RedTeamClientError(response["error"])
|
|
312
|
-
print(f"Response: {response}")
|
|
312
|
+
# print(f"Response: {response}")
|
|
313
313
|
return RedTeamResultSummary.from_dict(response)
|
|
314
314
|
|
|
315
315
|
def get_result_details(self, task_id: str = None, test_name: str = None):
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
enkryptai_sdk/__init__.py,sha256=rP6PtntJogJauj1lKWK8DkiBr3uYjireIUamr6aflu0,763
|
|
2
|
-
enkryptai_sdk/ai_proxy.py,sha256=
|
|
2
|
+
enkryptai_sdk/ai_proxy.py,sha256=pD6kPmD9H0gttN28cezgV7_IVelLXAHNR5cPeXCM8Ew,3799
|
|
3
3
|
enkryptai_sdk/base.py,sha256=MlEDcEIjXo35kat9XkGUu7VB2fIvJk38C94wAeO9bEw,1304
|
|
4
4
|
enkryptai_sdk/config.py,sha256=IpB8_aO4zXdvv061v24oh83oyJ5Tp1QBQTzeuW4h9QY,8828
|
|
5
5
|
enkryptai_sdk/datasets.py,sha256=xekcdY9wIniw2TnylaK6o1RNZ5DRoluNOGawBkVgaM0,4881
|
|
6
6
|
enkryptai_sdk/deployments.py,sha256=qXoUQtLYRSqZsAAqPgxJAad1a3mgMAbPx09NiOyAdsw,4155
|
|
7
|
-
enkryptai_sdk/evals.py,sha256=
|
|
7
|
+
enkryptai_sdk/evals.py,sha256=BywyEgIT7xdJ58svO_sDNOMVowdB0RTGoAZPEbCnDVo,2595
|
|
8
8
|
enkryptai_sdk/guardrails.py,sha256=CtQwPBmpFFy71P22kG0gJbefYJflUT9aareYksPhNlQ,12096
|
|
9
9
|
enkryptai_sdk/guardrails_old.py,sha256=SgzPZkTzbAPD9XfmYNG6M1-TrzbhDHpAkI3FjnVWS_s,6434
|
|
10
|
-
enkryptai_sdk/models.py,sha256=
|
|
11
|
-
enkryptai_sdk/red_team.py,sha256=
|
|
10
|
+
enkryptai_sdk/models.py,sha256=FSdpfz-e1a0D7nuYCnQC859AdrOUVr60QbLR1mlZjp0,8978
|
|
11
|
+
enkryptai_sdk/red_team.py,sha256=jlSf7oNPM7jJHXyv37ROQgkluuigxbSpeeAfvKqUiGI,14192
|
|
12
12
|
enkryptai_sdk/response.py,sha256=43JRubzgGCpoVxYNzBZY0AlUgLbfcXD_AwD7wU3qY9o,4086
|
|
13
13
|
enkryptai_sdk/dto/__init__.py,sha256=kKBw4rkfqMBuK8nXRDtD6Sd0_uqLKgbcHrqzuSGJpr0,2310
|
|
14
14
|
enkryptai_sdk/dto/ai_proxy.py,sha256=clwMN4xdH8Zr55dnhilHbs-qaHRlCOrLPrij0Zd1Av0,11283
|
|
@@ -18,8 +18,8 @@ enkryptai_sdk/dto/deployments.py,sha256=lsKdG09C-rceIjGvEyYOBf5zBjrk7ma8NpPfgrAg
|
|
|
18
18
|
enkryptai_sdk/dto/guardrails.py,sha256=XMFco-KlEqI4TYoJAyxxTrk-OFixtEcftBpG1SXFH4k,39583
|
|
19
19
|
enkryptai_sdk/dto/models.py,sha256=O4gVhVTenlsytNJIvk2gO5530KZWMye6FCVCtF5IW-A,11700
|
|
20
20
|
enkryptai_sdk/dto/red_team.py,sha256=BoOPYFjIONIC0XPuyJtkx_qLVYi2kLGEA4CzlySgbJA,13829
|
|
21
|
-
enkryptai_sdk-1.0.
|
|
22
|
-
enkryptai_sdk-1.0.
|
|
23
|
-
enkryptai_sdk-1.0.
|
|
24
|
-
enkryptai_sdk-1.0.
|
|
25
|
-
enkryptai_sdk-1.0.
|
|
21
|
+
enkryptai_sdk-1.0.4.dist-info/licenses/LICENSE,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
22
|
+
enkryptai_sdk-1.0.4.dist-info/METADATA,sha256=2lqT-652SgRDCyjpMhmRfyUiF6dK1uL-kl0i1RbKhsc,43207
|
|
23
|
+
enkryptai_sdk-1.0.4.dist-info/WHEEL,sha256=CmyFI0kx5cdEMTLiONQRbGQwjIoR1aIYB7eCAQ4KPJ0,91
|
|
24
|
+
enkryptai_sdk-1.0.4.dist-info/top_level.txt,sha256=s2X9UJJwvJamNmr6ZXWyyQe60sXtQGWFuaBYfhgHI_4,14
|
|
25
|
+
enkryptai_sdk-1.0.4.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|