enkryptai-sdk 1.0.11__tar.gz → 1.0.13__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.
- {enkryptai_sdk-1.0.11/src/enkryptai_sdk.egg-info → enkryptai_sdk-1.0.13}/PKG-INFO +1 -1
- {enkryptai_sdk-1.0.11 → enkryptai_sdk-1.0.13}/setup.py +1 -1
- {enkryptai_sdk-1.0.11 → enkryptai_sdk-1.0.13}/src/enkryptai_sdk/dto/models.py +1 -0
- {enkryptai_sdk-1.0.11 → enkryptai_sdk-1.0.13}/src/enkryptai_sdk/dto/red_team.py +1 -0
- {enkryptai_sdk-1.0.11 → enkryptai_sdk-1.0.13}/src/enkryptai_sdk/models.py +2 -0
- {enkryptai_sdk-1.0.11 → enkryptai_sdk-1.0.13}/src/enkryptai_sdk/red_team.py +4 -12
- {enkryptai_sdk-1.0.11 → enkryptai_sdk-1.0.13/src/enkryptai_sdk.egg-info}/PKG-INFO +1 -1
- {enkryptai_sdk-1.0.11 → enkryptai_sdk-1.0.13}/tests/test_all_v2.py +55 -8
- {enkryptai_sdk-1.0.11 → enkryptai_sdk-1.0.13}/LICENSE +0 -0
- {enkryptai_sdk-1.0.11 → enkryptai_sdk-1.0.13}/README.md +0 -0
- {enkryptai_sdk-1.0.11 → enkryptai_sdk-1.0.13}/setup.cfg +0 -0
- {enkryptai_sdk-1.0.11 → enkryptai_sdk-1.0.13}/src/enkryptai_sdk/__init__.py +0 -0
- {enkryptai_sdk-1.0.11 → enkryptai_sdk-1.0.13}/src/enkryptai_sdk/ai_proxy.py +0 -0
- {enkryptai_sdk-1.0.11 → enkryptai_sdk-1.0.13}/src/enkryptai_sdk/base.py +0 -0
- {enkryptai_sdk-1.0.11 → enkryptai_sdk-1.0.13}/src/enkryptai_sdk/coc.py +0 -0
- {enkryptai_sdk-1.0.11 → enkryptai_sdk-1.0.13}/src/enkryptai_sdk/config.py +0 -0
- {enkryptai_sdk-1.0.11 → enkryptai_sdk-1.0.13}/src/enkryptai_sdk/datasets.py +0 -0
- {enkryptai_sdk-1.0.11 → enkryptai_sdk-1.0.13}/src/enkryptai_sdk/deployments.py +0 -0
- {enkryptai_sdk-1.0.11 → enkryptai_sdk-1.0.13}/src/enkryptai_sdk/dto/__init__.py +0 -0
- {enkryptai_sdk-1.0.11 → enkryptai_sdk-1.0.13}/src/enkryptai_sdk/dto/ai_proxy.py +0 -0
- {enkryptai_sdk-1.0.11 → enkryptai_sdk-1.0.13}/src/enkryptai_sdk/dto/base.py +0 -0
- {enkryptai_sdk-1.0.11 → enkryptai_sdk-1.0.13}/src/enkryptai_sdk/dto/coc.py +0 -0
- {enkryptai_sdk-1.0.11 → enkryptai_sdk-1.0.13}/src/enkryptai_sdk/dto/datasets.py +0 -0
- {enkryptai_sdk-1.0.11 → enkryptai_sdk-1.0.13}/src/enkryptai_sdk/dto/deployments.py +0 -0
- {enkryptai_sdk-1.0.11 → enkryptai_sdk-1.0.13}/src/enkryptai_sdk/dto/guardrails.py +0 -0
- {enkryptai_sdk-1.0.11 → enkryptai_sdk-1.0.13}/src/enkryptai_sdk/evals.py +0 -0
- {enkryptai_sdk-1.0.11 → enkryptai_sdk-1.0.13}/src/enkryptai_sdk/guardrails.py +0 -0
- {enkryptai_sdk-1.0.11 → enkryptai_sdk-1.0.13}/src/enkryptai_sdk/guardrails_old.py +0 -0
- {enkryptai_sdk-1.0.11 → enkryptai_sdk-1.0.13}/src/enkryptai_sdk/response.py +0 -0
- {enkryptai_sdk-1.0.11 → enkryptai_sdk-1.0.13}/src/enkryptai_sdk.egg-info/SOURCES.txt +0 -0
- {enkryptai_sdk-1.0.11 → enkryptai_sdk-1.0.13}/src/enkryptai_sdk.egg-info/dependency_links.txt +0 -0
- {enkryptai_sdk-1.0.11 → enkryptai_sdk-1.0.13}/src/enkryptai_sdk.egg-info/top_level.txt +0 -0
- {enkryptai_sdk-1.0.11 → enkryptai_sdk-1.0.13}/tests/test_ai_proxy.py +0 -0
- {enkryptai_sdk-1.0.11 → enkryptai_sdk-1.0.13}/tests/test_all.py +0 -0
- {enkryptai_sdk-1.0.11 → enkryptai_sdk-1.0.13}/tests/test_basic.py +0 -0
- {enkryptai_sdk-1.0.11 → enkryptai_sdk-1.0.13}/tests/test_coc.py +0 -0
- {enkryptai_sdk-1.0.11 → enkryptai_sdk-1.0.13}/tests/test_datasets.py +0 -0
- {enkryptai_sdk-1.0.11 → enkryptai_sdk-1.0.13}/tests/test_deployments.py +0 -0
- {enkryptai_sdk-1.0.11 → enkryptai_sdk-1.0.13}/tests/test_detect_policy.py +0 -0
- {enkryptai_sdk-1.0.11 → enkryptai_sdk-1.0.13}/tests/test_guardrails.py +0 -0
- {enkryptai_sdk-1.0.11 → enkryptai_sdk-1.0.13}/tests/test_injection_attack.py +0 -0
- {enkryptai_sdk-1.0.11 → enkryptai_sdk-1.0.13}/tests/test_model.py +0 -0
- {enkryptai_sdk-1.0.11 → enkryptai_sdk-1.0.13}/tests/test_openai.py +0 -0
- {enkryptai_sdk-1.0.11 → enkryptai_sdk-1.0.13}/tests/test_policy_violation.py +0 -0
- {enkryptai_sdk-1.0.11 → enkryptai_sdk-1.0.13}/tests/test_redteam.py +0 -0
|
@@ -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.
|
|
12
|
+
version="1.0.13", # 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",
|
|
@@ -166,6 +166,7 @@ class ModelConfigDetails(BaseDTO):
|
|
|
166
166
|
auth_data: AuthData = field(default_factory=AuthData)
|
|
167
167
|
input_modalities: List[InputModality] = field(default_factory=list)
|
|
168
168
|
output_modalities: List[OutputModality] = field(default_factory=list)
|
|
169
|
+
custom_curl_command: Optional[str] = None
|
|
169
170
|
custom_headers: List[CustomHeader] = field(default_factory=list)
|
|
170
171
|
custom_payload: Dict[str, Any] = field(default_factory=dict)
|
|
171
172
|
custom_response_content_type: Optional[str] = ""
|
|
@@ -359,6 +359,7 @@ class TargetModelConfiguration(BaseDTO):
|
|
|
359
359
|
model_api_key: Optional[str] = None
|
|
360
360
|
input_modalities: List[InputModality] = field(default_factory=list)
|
|
361
361
|
output_modalities: List[OutputModality] = field(default_factory=list)
|
|
362
|
+
custom_curl_command: Optional[str] = None
|
|
362
363
|
custom_headers: List[CustomHeader] = field(default_factory=list)
|
|
363
364
|
custom_payload: Dict[str, Any] = field(default_factory=dict)
|
|
364
365
|
custom_response_content_type: Optional[str] = ""
|
|
@@ -77,6 +77,7 @@ class ModelClient(BaseClient):
|
|
|
77
77
|
"tools": config.model_config.tools,
|
|
78
78
|
"input_modalities": [m.value if hasattr(m, 'value') else m for m in config.model_config.input_modalities],
|
|
79
79
|
"output_modalities": [m.value if hasattr(m, 'value') else m for m in config.model_config.output_modalities],
|
|
80
|
+
"custom_curl_command": config.model_config.custom_curl_command,
|
|
80
81
|
"custom_headers": custom_headers,
|
|
81
82
|
"custom_payload": config.model_config.custom_payload,
|
|
82
83
|
"custom_response_content_type": config.model_config.custom_response_content_type,
|
|
@@ -225,6 +226,7 @@ class ModelClient(BaseClient):
|
|
|
225
226
|
"tools": config.model_config.tools,
|
|
226
227
|
"input_modalities": [m.value if hasattr(m, 'value') else m for m in config.model_config.input_modalities],
|
|
227
228
|
"output_modalities": [m.value if hasattr(m, 'value') else m for m in config.model_config.output_modalities],
|
|
229
|
+
"custom_curl_command": config.model_config.custom_curl_command,
|
|
228
230
|
"custom_headers": custom_headers,
|
|
229
231
|
"custom_payload": config.model_config.custom_payload,
|
|
230
232
|
"custom_response_content_type": config.model_config.custom_response_content_type,
|
|
@@ -106,9 +106,7 @@ class RedTeamClient(BaseClient):
|
|
|
106
106
|
# "async": config.async_enabled,
|
|
107
107
|
"dataset_name": config.dataset_name,
|
|
108
108
|
"test_name": config.test_name,
|
|
109
|
-
"redteam_test_configurations":
|
|
110
|
-
k: v.to_dict() for k, v in test_configs.items()
|
|
111
|
-
},
|
|
109
|
+
"redteam_test_configurations": test_configs,
|
|
112
110
|
}
|
|
113
111
|
|
|
114
112
|
if config.target_model_configuration:
|
|
@@ -153,9 +151,7 @@ class RedTeamClient(BaseClient):
|
|
|
153
151
|
# "async": config.async_enabled,
|
|
154
152
|
"dataset_name": config.dataset_name,
|
|
155
153
|
"test_name": config.test_name,
|
|
156
|
-
"redteam_test_configurations":
|
|
157
|
-
k: v.to_dict() for k, v in test_configs.items()
|
|
158
|
-
},
|
|
154
|
+
"redteam_test_configurations": test_configs,
|
|
159
155
|
}
|
|
160
156
|
|
|
161
157
|
headers = {
|
|
@@ -196,9 +192,7 @@ class RedTeamClient(BaseClient):
|
|
|
196
192
|
payload = {
|
|
197
193
|
# "async": config.async_enabled,
|
|
198
194
|
"test_name": config.test_name,
|
|
199
|
-
"redteam_test_configurations":
|
|
200
|
-
k: v.to_dict() for k, v in test_configs.items()
|
|
201
|
-
},
|
|
195
|
+
"redteam_test_configurations": test_configs,
|
|
202
196
|
}
|
|
203
197
|
|
|
204
198
|
if config.dataset_configuration:
|
|
@@ -252,9 +246,7 @@ class RedTeamClient(BaseClient):
|
|
|
252
246
|
payload = {
|
|
253
247
|
# "async": config.async_enabled,
|
|
254
248
|
"test_name": config.test_name,
|
|
255
|
-
"redteam_test_configurations":
|
|
256
|
-
k: v.to_dict() for k, v in test_configs.items()
|
|
257
|
-
},
|
|
249
|
+
"redteam_test_configurations": test_configs,
|
|
258
250
|
}
|
|
259
251
|
|
|
260
252
|
if config.dataset_configuration:
|
|
@@ -19,6 +19,7 @@ test_guardrails_policy_name = "Test Guardrails Policy"
|
|
|
19
19
|
model_saved_name = None
|
|
20
20
|
model_version = None
|
|
21
21
|
test_model_saved_name = "Test Model"
|
|
22
|
+
test_custom_model_saved_name = "Test Custom Model"
|
|
22
23
|
test_model_version = "v1"
|
|
23
24
|
test_deployment_name = "test-deployment"
|
|
24
25
|
|
|
@@ -155,6 +156,7 @@ def sample_detectors():
|
|
|
155
156
|
},
|
|
156
157
|
}
|
|
157
158
|
|
|
159
|
+
|
|
158
160
|
@pytest.fixture
|
|
159
161
|
def sample_model_config():
|
|
160
162
|
return {
|
|
@@ -162,6 +164,23 @@ def sample_model_config():
|
|
|
162
164
|
"model_version": test_model_version,
|
|
163
165
|
"testing_for": "foundationModels",
|
|
164
166
|
"model_name": model_name,
|
|
167
|
+
"model_config": {
|
|
168
|
+
"model_provider": model_provider,
|
|
169
|
+
"endpoint_url": model_endpoint_url,
|
|
170
|
+
"apikey": OPENAI_API_KEY,
|
|
171
|
+
"input_modalities": ["text"],
|
|
172
|
+
"output_modalities": ["text"],
|
|
173
|
+
},
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
|
|
177
|
+
@pytest.fixture
|
|
178
|
+
def sample_custom_model_config():
|
|
179
|
+
return {
|
|
180
|
+
"model_saved_name": test_custom_model_saved_name,
|
|
181
|
+
"model_version": test_model_version,
|
|
182
|
+
"testing_for": "foundationModels",
|
|
183
|
+
"model_name": model_name,
|
|
165
184
|
"model_config": {
|
|
166
185
|
# "model_provider": model_provider,
|
|
167
186
|
"model_provider": "custom",
|
|
@@ -193,6 +212,7 @@ def sample_model_config():
|
|
|
193
212
|
},
|
|
194
213
|
}
|
|
195
214
|
|
|
215
|
+
|
|
196
216
|
@pytest.fixture
|
|
197
217
|
def sample_deployment_config():
|
|
198
218
|
return {
|
|
@@ -945,6 +965,20 @@ def test_add_model(model_client, sample_model_config):
|
|
|
945
965
|
assert model_info["model_saved_name"] == test_model_saved_name
|
|
946
966
|
assert model_info["model_version"] == test_model_version
|
|
947
967
|
|
|
968
|
+
def test_add_custom_model(model_client, sample_custom_model_config):
|
|
969
|
+
print("\n\nTesting adding a new custom model")
|
|
970
|
+
response = model_client.add_model(config=sample_custom_model_config)
|
|
971
|
+
print("\nResponse from adding a new custom model: ", response)
|
|
972
|
+
print("\nResponse data type: ", type(response))
|
|
973
|
+
assert response is not None
|
|
974
|
+
# assert hasattr(response, "message")
|
|
975
|
+
assert response.message == "Model details added successfully"
|
|
976
|
+
# assert hasattr(response, "data")
|
|
977
|
+
model_info = response.data
|
|
978
|
+
assert model_info is not None
|
|
979
|
+
assert model_info["model_saved_name"] == test_custom_model_saved_name
|
|
980
|
+
assert model_info["model_version"] == test_model_version
|
|
981
|
+
|
|
948
982
|
def test_list_models(model_client):
|
|
949
983
|
print("\n\nTesting list_models")
|
|
950
984
|
# Test the list_models method
|
|
@@ -972,11 +1006,16 @@ def test_get_model(model_client):
|
|
|
972
1006
|
# model_saved_name = model_info.model_saved_name
|
|
973
1007
|
# assert model_saved_name is not None
|
|
974
1008
|
# print("\nPicked model in get_model: ", model_saved_name)
|
|
1009
|
+
# -------------------------------
|
|
1010
|
+
# NOTE: Using custom model here is breaking AI Proxy as model_saved_name is a global variable
|
|
1011
|
+
# -------------------------------
|
|
1012
|
+
# model_saved_name = test_custom_model_saved_name
|
|
975
1013
|
model_saved_name = test_model_saved_name
|
|
976
1014
|
model_version = test_model_version
|
|
977
1015
|
|
|
978
1016
|
# Now test the get_model method
|
|
979
1017
|
model = model_client.get_model(model_saved_name=model_saved_name, model_version=model_version)
|
|
1018
|
+
# print("\nGET Model: ", model)
|
|
980
1019
|
assert model is not None
|
|
981
1020
|
# assert hasattr(model, "model_id")
|
|
982
1021
|
assert model.model_saved_name == model_saved_name
|
|
@@ -984,10 +1023,10 @@ def test_get_model(model_client):
|
|
|
984
1023
|
# assert hasattr(model, "status")
|
|
985
1024
|
|
|
986
1025
|
|
|
987
|
-
def test_modify_model(model_client,
|
|
988
|
-
print("\n\nTesting modifying
|
|
1026
|
+
def test_modify_model(model_client, sample_custom_model_config):
|
|
1027
|
+
print("\n\nTesting modifying custom model")
|
|
989
1028
|
# Test creating a new model
|
|
990
|
-
response = model_client.modify_model(config=
|
|
1029
|
+
response = model_client.modify_model(config=sample_custom_model_config, old_model_saved_name=None, old_model_version=None)
|
|
991
1030
|
print("\nResponse from modifying a new model: ", response)
|
|
992
1031
|
print("\nResponse data type: ", type(response))
|
|
993
1032
|
assert response is not None
|
|
@@ -996,7 +1035,7 @@ def test_modify_model(model_client, sample_model_config):
|
|
|
996
1035
|
# assert hasattr(response, "data")
|
|
997
1036
|
model_info = response.data
|
|
998
1037
|
assert model_info is not None
|
|
999
|
-
assert model_info["model_saved_name"] ==
|
|
1038
|
+
assert model_info["model_saved_name"] == test_custom_model_saved_name
|
|
1000
1039
|
assert model_info["model_version"] == test_model_version
|
|
1001
1040
|
print("\nSleeping for 60 seconds after model tests...")
|
|
1002
1041
|
time.sleep(60)
|
|
@@ -1006,7 +1045,7 @@ def test_modify_model(model_client, sample_model_config):
|
|
|
1006
1045
|
# Tests for Deployment Endpoints
|
|
1007
1046
|
# ----------------------------
|
|
1008
1047
|
|
|
1009
|
-
def
|
|
1048
|
+
def test_add_deployment(deployment_client, sample_deployment_config):
|
|
1010
1049
|
response = deployment_client.add_deployment(config=sample_deployment_config)
|
|
1011
1050
|
assert response is not None
|
|
1012
1051
|
assert hasattr(response, "from_dict")
|
|
@@ -1097,7 +1136,7 @@ def test_401_err_chat(ai_proxy_err_client, sample_chat_body):
|
|
|
1097
1136
|
# Tests for Dataset Endpoints
|
|
1098
1137
|
# ----------------------------
|
|
1099
1138
|
|
|
1100
|
-
def
|
|
1139
|
+
def test_add_dataset(dataset_client, sample_dataset_config):
|
|
1101
1140
|
print("\n\nTesting add_dataset")
|
|
1102
1141
|
response = dataset_client.add_dataset(config=sample_dataset_config)
|
|
1103
1142
|
print("\nAdd Dataset Response: ", response)
|
|
@@ -1233,7 +1272,7 @@ def test_get_health(redteam_client):
|
|
|
1233
1272
|
|
|
1234
1273
|
def test_saved_model_health(redteam_client):
|
|
1235
1274
|
print("\n\nTesting check_saved_model_health")
|
|
1236
|
-
response = redteam_client.check_saved_model_health(model_saved_name=
|
|
1275
|
+
response = redteam_client.check_saved_model_health(model_saved_name=test_custom_model_saved_name, model_version=test_model_version)
|
|
1237
1276
|
print("\nResponse from check_saved_model_health: ", response)
|
|
1238
1277
|
assert response is not None
|
|
1239
1278
|
assert hasattr(response, "status")
|
|
@@ -1297,7 +1336,7 @@ def test_saved_model_health(redteam_client):
|
|
|
1297
1336
|
|
|
1298
1337
|
def test_add_custom_task_with_saved_model(redteam_client, sample_custom_redteam_model_config):
|
|
1299
1338
|
print("\n\nTesting adding a new custom redteam task with saved model")
|
|
1300
|
-
response = redteam_client.add_custom_task_with_saved_model(config=sample_custom_redteam_model_config, model_saved_name=
|
|
1339
|
+
response = redteam_client.add_custom_task_with_saved_model(config=sample_custom_redteam_model_config, model_saved_name=test_custom_model_saved_name, model_version=test_model_version)
|
|
1301
1340
|
print("\nResponse from adding a new custom redteam task with saved model: ", response)
|
|
1302
1341
|
assert response is not None
|
|
1303
1342
|
assert hasattr(response, "task_id")
|
|
@@ -1439,6 +1478,14 @@ def test_delete_model(model_client):
|
|
|
1439
1478
|
# assert hasattr(response, "message")
|
|
1440
1479
|
assert response.message == "Model details deleted successfully"
|
|
1441
1480
|
|
|
1481
|
+
def test_delete_custom_model(model_client):
|
|
1482
|
+
print("\n\nTesting delete_custom_model")
|
|
1483
|
+
response = model_client.delete_model(model_saved_name=test_custom_model_saved_name, model_version=test_model_version)
|
|
1484
|
+
print("\nResponse from delete_custom_model: ", response)
|
|
1485
|
+
assert response is not None
|
|
1486
|
+
# assert hasattr(response, "message")
|
|
1487
|
+
assert response.message == "Model details deleted successfully"
|
|
1488
|
+
|
|
1442
1489
|
def test_delete_deployment(deployment_client):
|
|
1443
1490
|
print("\n\nTesting delete_deployment")
|
|
1444
1491
|
response = deployment_client.delete_deployment(deployment_name=test_deployment_name)
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{enkryptai_sdk-1.0.11 → enkryptai_sdk-1.0.13}/src/enkryptai_sdk.egg-info/dependency_links.txt
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|