pangea-sdk 5.2.0b2__py3-none-any.whl → 5.2.1__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.
- pangea/__init__.py +1 -1
- pangea/asyncio/request.py +18 -9
- pangea/asyncio/services/__init__.py +0 -2
- pangea/asyncio/services/audit.py +6 -10
- pangea/asyncio/services/authz.py +23 -2
- pangea/asyncio/services/base.py +15 -1
- pangea/asyncio/services/intel.py +3 -0
- pangea/asyncio/services/redact.py +12 -0
- pangea/asyncio/services/sanitize.py +26 -2
- pangea/asyncio/services/share.py +23 -1
- pangea/deep_verify.py +7 -1
- pangea/dump_audit.py +8 -7
- pangea/request.py +16 -7
- pangea/services/__init__.py +0 -2
- pangea/services/audit/audit.py +5 -10
- pangea/services/authz.py +21 -1
- pangea/services/base.py +14 -1
- pangea/services/intel.py +18 -0
- pangea/services/redact.py +28 -0
- pangea/services/sanitize.py +22 -0
- pangea/services/share/share.py +23 -1
- {pangea_sdk-5.2.0b2.dist-info → pangea_sdk-5.2.1.dist-info}/METADATA +4 -4
- {pangea_sdk-5.2.0b2.dist-info → pangea_sdk-5.2.1.dist-info}/RECORD +24 -28
- pangea/asyncio/services/ai_guard.py +0 -75
- pangea/asyncio/services/prompt_guard.py +0 -73
- pangea/services/ai_guard.py +0 -157
- pangea/services/prompt_guard.py +0 -83
- {pangea_sdk-5.2.0b2.dist-info → pangea_sdk-5.2.1.dist-info}/WHEEL +0 -0
pangea/services/redact.py
CHANGED
@@ -66,6 +66,17 @@ class RedactRequest(APIRequestModel):
|
|
66
66
|
rulesets: Optional[List[str]] = None
|
67
67
|
return_result: Optional[bool] = None
|
68
68
|
redaction_method_overrides: Optional[RedactionMethodOverrides] = None
|
69
|
+
vault_parameters: Optional[VaultParameters] = None
|
70
|
+
llm_request: Optional[bool] = None
|
71
|
+
"""Is this redact call going to be used in an LLM request?"""
|
72
|
+
|
73
|
+
|
74
|
+
class VaultParameters(APIRequestModel):
|
75
|
+
fpe_key_id: Optional[str] = None
|
76
|
+
"""A vault key ID of an exportable key used to redact with FPE instead of using the service config default."""
|
77
|
+
|
78
|
+
salt_secret_id: Optional[str] = None
|
79
|
+
"""A vault secret ID of a secret used to salt a hash instead of using the service config default."""
|
69
80
|
|
70
81
|
|
71
82
|
class RecognizerResult(APIResponseModel):
|
@@ -108,11 +119,13 @@ class RedactResult(PangeaResponseResult):
|
|
108
119
|
redact_text: Redacted text result
|
109
120
|
count: Number of redactions present in the text
|
110
121
|
report: Describes the decision process for redactions
|
122
|
+
fpe_context: FPE context used to encrypt and redact data
|
111
123
|
"""
|
112
124
|
|
113
125
|
redacted_text: Optional[str] = None
|
114
126
|
count: int
|
115
127
|
report: Optional[DebugReport] = None
|
128
|
+
fpe_context: Optional[str] = None
|
116
129
|
|
117
130
|
|
118
131
|
class StructuredRequest(APIRequestModel):
|
@@ -134,6 +147,9 @@ class StructuredRequest(APIRequestModel):
|
|
134
147
|
rulesets: Optional[List[str]] = None
|
135
148
|
return_result: Optional[bool] = None
|
136
149
|
redaction_method_overrides: Optional[RedactionMethodOverrides] = None
|
150
|
+
vault_parameters: Optional[VaultParameters] = None
|
151
|
+
llm_request: Optional[bool] = None
|
152
|
+
"""Is this redact call going to be used in an LLM request?"""
|
137
153
|
|
138
154
|
|
139
155
|
class StructuredResult(PangeaResponseResult):
|
@@ -228,6 +244,8 @@ class Redact(ServiceBase):
|
|
228
244
|
rulesets: Optional[List[str]] = None,
|
229
245
|
return_result: Optional[bool] = None,
|
230
246
|
redaction_method_overrides: Optional[RedactionMethodOverrides] = None,
|
247
|
+
llm_request: Optional[bool] = None,
|
248
|
+
vault_parameters: Optional[VaultParameters] = None,
|
231
249
|
) -> PangeaResponse[RedactResult]:
|
232
250
|
"""
|
233
251
|
Redact
|
@@ -244,6 +262,8 @@ class Redact(ServiceBase):
|
|
244
262
|
rulesets (list[str], optional): An array of redact rulesets short names
|
245
263
|
return_result(bool, optional): Setting this value to false will omit the redacted result only returning count
|
246
264
|
redaction_method_overrides: A set of redaction method overrides for any enabled rule. These methods override the config declared methods
|
265
|
+
llm_request: Boolean flag to enable FPE redaction for LLM requests
|
266
|
+
vault_parameters: A set of vault parameters to use for redaction
|
247
267
|
|
248
268
|
Raises:
|
249
269
|
PangeaAPIException: If an API Error happens
|
@@ -264,6 +284,8 @@ class Redact(ServiceBase):
|
|
264
284
|
rulesets=rulesets,
|
265
285
|
return_result=return_result,
|
266
286
|
redaction_method_overrides=redaction_method_overrides,
|
287
|
+
llm_request=llm_request,
|
288
|
+
vault_parameters=vault_parameters,
|
267
289
|
)
|
268
290
|
return self.request.post("v1/redact", RedactResult, data=input.model_dump(exclude_none=True))
|
269
291
|
|
@@ -277,6 +299,8 @@ class Redact(ServiceBase):
|
|
277
299
|
rulesets: Optional[List[str]] = None,
|
278
300
|
return_result: Optional[bool] = None,
|
279
301
|
redaction_method_overrides: Optional[RedactionMethodOverrides] = None,
|
302
|
+
llm_request: Optional[bool] = None,
|
303
|
+
vault_parameters: Optional[VaultParameters] = None,
|
280
304
|
) -> PangeaResponse[StructuredResult]:
|
281
305
|
"""
|
282
306
|
Redact structured
|
@@ -297,6 +321,8 @@ class Redact(ServiceBase):
|
|
297
321
|
rulesets (list[str], optional): An array of redact rulesets short names
|
298
322
|
return_result(bool, optional): Setting this value to false will omit the redacted result only returning count
|
299
323
|
redaction_method_overrides: A set of redaction method overrides for any enabled rule. These methods override the config declared methods
|
324
|
+
llm_request: Boolean flag to enable FPE redaction for LLM requests
|
325
|
+
vault_parameters: A set of vault parameters to use for redaction
|
300
326
|
|
301
327
|
Raises:
|
302
328
|
PangeaAPIException: If an API Error happens
|
@@ -324,6 +350,8 @@ class Redact(ServiceBase):
|
|
324
350
|
rulesets=rulesets,
|
325
351
|
return_result=return_result,
|
326
352
|
redaction_method_overrides=redaction_method_overrides,
|
353
|
+
llm_request=llm_request,
|
354
|
+
vault_parameters=vault_parameters,
|
327
355
|
)
|
328
356
|
return self.request.post("v1/redact_structured", StructuredResult, data=input.model_dump(exclude_none=True))
|
329
357
|
|
pangea/services/sanitize.py
CHANGED
@@ -7,6 +7,7 @@ from typing import Dict, List, Optional, Tuple
|
|
7
7
|
|
8
8
|
from pydantic import Field
|
9
9
|
|
10
|
+
from pangea.config import PangeaConfig
|
10
11
|
from pangea.response import APIRequestModel, PangeaResponse, PangeaResponseResult, TransferMethod
|
11
12
|
from pangea.services.base import ServiceBase
|
12
13
|
from pangea.utils import FileUploadParams, get_file_upload_params
|
@@ -197,6 +198,27 @@ class Sanitize(ServiceBase):
|
|
197
198
|
|
198
199
|
service_name = "sanitize"
|
199
200
|
|
201
|
+
def __init__(
|
202
|
+
self, token: str, config: PangeaConfig | None = None, logger_name: str = "pangea", config_id: str | None = None
|
203
|
+
) -> None:
|
204
|
+
"""
|
205
|
+
Sanitize client
|
206
|
+
|
207
|
+
Initializes a new Sanitize client.
|
208
|
+
|
209
|
+
Args:
|
210
|
+
token: Pangea API token.
|
211
|
+
config: Configuration.
|
212
|
+
logger_name: Logger name.
|
213
|
+
config_id: Configuration ID.
|
214
|
+
|
215
|
+
Examples:
|
216
|
+
config = PangeaConfig(domain="aws.us.pangea.cloud")
|
217
|
+
authz = Sanitize(token="pangea_token", config=config)
|
218
|
+
"""
|
219
|
+
|
220
|
+
super().__init__(token, config, logger_name, config_id=config_id)
|
221
|
+
|
200
222
|
def sanitize(
|
201
223
|
self,
|
202
224
|
transfer_method: TransferMethod = TransferMethod.POST_URL,
|
pangea/services/share/share.py
CHANGED
@@ -6,6 +6,7 @@ import enum
|
|
6
6
|
import io
|
7
7
|
from typing import Dict, List, NewType, Optional, Tuple, Union
|
8
8
|
|
9
|
+
from pangea.config import PangeaConfig
|
9
10
|
from pangea.response import APIRequestModel, PangeaResponse, PangeaResponseResult, TransferMethod
|
10
11
|
from pangea.services.base import ServiceBase
|
11
12
|
from pangea.services.share.file_format import FileFormat
|
@@ -669,10 +670,31 @@ class BucketsResult(PangeaResponseResult):
|
|
669
670
|
|
670
671
|
|
671
672
|
class Share(ServiceBase):
|
672
|
-
"""Share service client."""
|
673
|
+
"""Secure Share service client."""
|
673
674
|
|
674
675
|
service_name = "share"
|
675
676
|
|
677
|
+
def __init__(
|
678
|
+
self, token: str, config: PangeaConfig | None = None, logger_name: str = "pangea", config_id: str | None = None
|
679
|
+
) -> None:
|
680
|
+
"""
|
681
|
+
Secure Share client
|
682
|
+
|
683
|
+
Initializes a new Secure Share client.
|
684
|
+
|
685
|
+
Args:
|
686
|
+
token: Pangea API token.
|
687
|
+
config: Configuration.
|
688
|
+
logger_name: Logger name.
|
689
|
+
config_id: Configuration ID.
|
690
|
+
|
691
|
+
Examples:
|
692
|
+
config = PangeaConfig(domain="aws.us.pangea.cloud")
|
693
|
+
authz = Share(token="pangea_token", config=config)
|
694
|
+
"""
|
695
|
+
|
696
|
+
super().__init__(token, config, logger_name, config_id=config_id)
|
697
|
+
|
676
698
|
def buckets(self) -> PangeaResponse[BucketsResult]:
|
677
699
|
"""
|
678
700
|
Buckets
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.1
|
2
2
|
Name: pangea-sdk
|
3
|
-
Version: 5.2.
|
3
|
+
Version: 5.2.1
|
4
4
|
Summary: Pangea API SDK
|
5
5
|
Home-page: https://pangea.cloud/docs/sdk/python/
|
6
6
|
License: MIT
|
@@ -17,11 +17,11 @@ Classifier: Programming Language :: Python :: 3.12
|
|
17
17
|
Classifier: Programming Language :: Python :: 3.13
|
18
18
|
Classifier: Topic :: Software Development
|
19
19
|
Classifier: Topic :: Software Development :: Libraries
|
20
|
-
Requires-Dist: aiohttp (>=3.
|
20
|
+
Requires-Dist: aiohttp (>=3.11.10,<4.0.0)
|
21
21
|
Requires-Dist: cryptography (>=43.0.3,<44.0.0)
|
22
|
-
Requires-Dist: deprecated (>=1.2.
|
22
|
+
Requires-Dist: deprecated (>=1.2.15,<2.0.0)
|
23
23
|
Requires-Dist: google-crc32c (>=1.5.0,<2.0.0)
|
24
|
-
Requires-Dist: pydantic (>=2.
|
24
|
+
Requires-Dist: pydantic (>=2.10.3,<3.0.0)
|
25
25
|
Requires-Dist: python-dateutil (>=2.9.0,<3.0.0)
|
26
26
|
Requires-Dist: requests (>=2.31.0,<3.0.0)
|
27
27
|
Requires-Dist: requests-toolbelt (>=1.0.0,<2.0.0)
|
@@ -1,51 +1,47 @@
|
|
1
|
-
pangea/__init__.py,sha256=
|
1
|
+
pangea/__init__.py,sha256=YdVCSgR-OBewhxnne1SnOliwM7KXiu_EV88j_zSLRmM,246
|
2
2
|
pangea/asyncio/__init__.py,sha256=kjEMkqMQ521LlMSu5jn3_WgweyArwVZ2C-s3x7mR6Pk,45
|
3
3
|
pangea/asyncio/file_uploader.py,sha256=wI7epib7Rc5jtZw4eJ1L1SlmutDG6CPv59C8N2UPhtY,1436
|
4
|
-
pangea/asyncio/request.py,sha256=
|
5
|
-
pangea/asyncio/services/__init__.py,sha256=
|
6
|
-
pangea/asyncio/services/
|
7
|
-
pangea/asyncio/services/audit.py,sha256=bZ7gdkVWkzqLqUVc1Wnf3oDAaCLg97-zTWhY8UdX0_Y,26549
|
4
|
+
pangea/asyncio/request.py,sha256=BREsLY8_MCxGSplHbdKFZTzr4TX5ya0-BsXLffZhsco,17849
|
5
|
+
pangea/asyncio/services/__init__.py,sha256=3IkiTqY_RtFndI7aoDTrb1yLv8xos_cKhmGS1TULcmw,386
|
6
|
+
pangea/asyncio/services/audit.py,sha256=rPaCx4cMzj-g9WFMRIysFCJAz6Btp6YrhcKe_exky8k,26283
|
8
7
|
pangea/asyncio/services/authn.py,sha256=rPeLJweL8mYH_t4ebcQn4n_Wglr3kClKNnCXNCimZU4,46622
|
9
|
-
pangea/asyncio/services/authz.py,sha256=
|
10
|
-
pangea/asyncio/services/base.py,sha256=
|
8
|
+
pangea/asyncio/services/authz.py,sha256=B_0_nhDMJcjNpjpCx3Vi2LDRhlmfV9325GKbUZ8reos,10025
|
9
|
+
pangea/asyncio/services/base.py,sha256=vRFVcO_uEAGJte3OUUBLD43RoiiFB1vC7SPyN6yEMoA,3158
|
11
10
|
pangea/asyncio/services/embargo.py,sha256=ctzj3kip6xos-Eu3JuOskrCGYC8T3JlsgAopZHiPSXM,3068
|
12
11
|
pangea/asyncio/services/file_scan.py,sha256=PLG1O-PL4Yk9uY9D6NbMrZ5LHg70Z311s7bFe46UMZA,7108
|
13
|
-
pangea/asyncio/services/intel.py,sha256=
|
14
|
-
pangea/asyncio/services/
|
15
|
-
pangea/asyncio/services/
|
16
|
-
pangea/asyncio/services/
|
17
|
-
pangea/asyncio/services/share.py,sha256=UYJeUKA3NLSFA8R0X7B6yBi2U1g4q04O4ftrp9SMCzA,26097
|
12
|
+
pangea/asyncio/services/intel.py,sha256=Iwz_DleAPtmd1taekT4W8lVo65uHjIvA4TQ7WUQGrRk,38306
|
13
|
+
pangea/asyncio/services/redact.py,sha256=JPJcmeKFloMZRpkjAHAZbpZJpO993WsTfEwA-S5ov18,7951
|
14
|
+
pangea/asyncio/services/sanitize.py,sha256=4pRWBH595kFUXBkmu8euyk6H7F1M_-xXB2Qxnz6St6c,8627
|
15
|
+
pangea/asyncio/services/share.py,sha256=YPJm_Gc4tfcx2cX6P_vLWIsHOR6M3RYy9LdU2UzEZbk,26791
|
18
16
|
pangea/asyncio/services/vault.py,sha256=VqrJGSEdq6MlZRI6cJpkthhIsqLClSQdgVxwYCbIwEk,77079
|
19
17
|
pangea/audit_logger.py,sha256=gRkCfUUT5LDNaycwxkhZUySgY47jDfn1ZeKOul4XCQI,3842
|
20
18
|
pangea/config.py,sha256=mQUu8GX_6weIuv3vjNdG5plppXskXYASmxMWtFQh-hc,1662
|
21
19
|
pangea/crypto/rsa.py,sha256=mwSiNy571KAGr3F6oEM0CXWkl9D023ch8ldbZZeLj_4,4747
|
22
|
-
pangea/deep_verify.py,sha256=
|
20
|
+
pangea/deep_verify.py,sha256=ZGraaL7TCxwRBIDqjBFR0clKlhAC-Yce6kD-1LClhG8,8616
|
23
21
|
pangea/deprecated.py,sha256=IjFYEVvY1E0ld0SMkEYC1o62MAleX3nnT1If2dFVbHo,608
|
24
|
-
pangea/dump_audit.py,sha256=
|
22
|
+
pangea/dump_audit.py,sha256=IevqaUUh7GDepdIW7slSxeZbkPrWIVbcX3sr4DgpJXI,7090
|
25
23
|
pangea/exceptions.py,sha256=OBtzUECpNa6vNp8ySkHC-tm4QjFRCOAHBkMHqzAlOu8,5656
|
26
24
|
pangea/file_uploader.py,sha256=4RQ44xt-faApC61nn2PlwHT7XYrJ4GeQA8Ug4tySEAg,1227
|
27
25
|
pangea/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
28
|
-
pangea/request.py,sha256=
|
26
|
+
pangea/request.py,sha256=zxFvqbeGYtxN29nS8SPPZKlcGCqdUtenxaq84pQ4cxs,24807
|
29
27
|
pangea/response.py,sha256=lPAcYsF9Xg166CiyhCofVmQA-W4jevh0MQXxUa8Re68,7737
|
30
|
-
pangea/services/__init__.py,sha256
|
31
|
-
pangea/services/
|
32
|
-
pangea/services/audit/audit.py,sha256=IFv7jANA8S2SypQVS47x94_Cr5Z9zSsL9Dp9eXw9RHk,39593
|
28
|
+
pangea/services/__init__.py,sha256=-QsZxRzRq_V1x1lmS_mu4310MNm0DkM4r6g6rfVGnOc,340
|
29
|
+
pangea/services/audit/audit.py,sha256=7-c9l7jyGtpG7SqRUMpqsAzcUDhMZ5izgPalxHXsUvM,39320
|
33
30
|
pangea/services/audit/exceptions.py,sha256=bhVuYe4ammacOVxwg98CChxvwZf5FKgR2DcgqILOcwc,471
|
34
31
|
pangea/services/audit/models.py,sha256=1h1B9eSYQMYG3f8WNi1UcDX2-impRrET_ErjJYUnj7M,14678
|
35
32
|
pangea/services/audit/signing.py,sha256=5A4hvPtpfP2kMz8bsiiKUACriXbh5dv9gb_rbqiUtuI,5583
|
36
33
|
pangea/services/audit/util.py,sha256=Zq1qvfeplYfhCP_ud5YMvntSB0UvnCdsuYbOzZkHbjg,7620
|
37
34
|
pangea/services/authn/authn.py,sha256=cZKl2Ixc6HwHnkRecpSaAGTQUgaZUtxfLa0T3S03HMs,45478
|
38
35
|
pangea/services/authn/models.py,sha256=HH5su6jx3O9AwVGzASXZ99-eIWjgXEP5LhIVdewM13s,22394
|
39
|
-
pangea/services/authz.py,sha256=
|
40
|
-
pangea/services/base.py,sha256=
|
36
|
+
pangea/services/authz.py,sha256=bB0ZEUuXLT7Xjs5kZef1hZK6Du6VUusHe5aekNaxamw,12746
|
37
|
+
pangea/services/base.py,sha256=43pWQcR9CeT4sGzgctF3Sy4M_h7DaUzkuZD2Z7CcDUU,3845
|
41
38
|
pangea/services/embargo.py,sha256=9Wfku4td5ORaIENKmnGmS5jxJJIRfWp6Q51L36Jsy0I,3897
|
42
39
|
pangea/services/file_scan.py,sha256=QiO80uKqB_BnAOiYQKznXfxpa5j40qqETE3-zBRT_QE,7813
|
43
|
-
pangea/services/intel.py,sha256=
|
44
|
-
pangea/services/
|
45
|
-
pangea/services/
|
46
|
-
pangea/services/sanitize.py,sha256=XP5D4CcbCZfzgU567X6H5eFBWwZuYSsHdvsdrQAZekY,12767
|
40
|
+
pangea/services/intel.py,sha256=flVdK4WhllPutCkWh7H-MuBxMMz0f4Bl-fz2f-hPuWM,52679
|
41
|
+
pangea/services/redact.py,sha256=ovIcT0jkXe57O7keGzSClWNCic8y-4NZoemXoSKjjww,12913
|
42
|
+
pangea/services/sanitize.py,sha256=D_R_XIe9FvRCX40b8b_3gouhAGduDdxI9bT2w-kiVHU,13444
|
47
43
|
pangea/services/share/file_format.py,sha256=1svO1ee_aenA9zoO_AaU-Rk5Ulp7kcPOc_KwNoluyQE,2797
|
48
|
-
pangea/services/share/share.py,sha256=
|
44
|
+
pangea/services/share/share.py,sha256=8N4zXQJjkVDf2iR62pz6xpmxlbXRPNfHgYfOuEdNaZ8,46333
|
49
45
|
pangea/services/vault/models/asymmetric.py,sha256=vspijmEvHm5WXri_fjOWfQc4maYyZfhDkLuaTM8-PZo,4991
|
50
46
|
pangea/services/vault/models/common.py,sha256=PSZRFqHTUtEMJJGwywEFM2AU3aV8S-sbcoo3LLQ6uTc,17981
|
51
47
|
pangea/services/vault/models/keys.py,sha256=duAuTiOby_D7MloRvN4gNj0P-b-jx9sdtplAWFxsShw,2786
|
@@ -55,6 +51,6 @@ pangea/services/vault/vault.py,sha256=ow-Zm7PYzfWIfUcA4UNnpeL2DHfZM4C7inRDmNR3zQ
|
|
55
51
|
pangea/tools.py,sha256=2-Y4SAHWFv6Ocj42J_bWrVy27M5G3wi7a8LJn0dabHc,6427
|
56
52
|
pangea/utils.py,sha256=dZ6MwFVEWXUgXvvDg-k6JnvVfsgslvtaBd7ez7afrqk,4983
|
57
53
|
pangea/verify_audit.py,sha256=nSP17OzoSPdvezRExwfcf45H8ZPZnxZu-CbEp3qFJO0,17354
|
58
|
-
pangea_sdk-5.2.
|
59
|
-
pangea_sdk-5.2.
|
60
|
-
pangea_sdk-5.2.
|
54
|
+
pangea_sdk-5.2.1.dist-info/METADATA,sha256=YjlZ9hj9YmyyMIeS6Z_eSbpBeHsh_QNfzwxfbexlZVs,7513
|
55
|
+
pangea_sdk-5.2.1.dist-info/WHEEL,sha256=Nq82e9rUAnEjt98J6MlVmMCZb-t9cYE2Ir1kpBmnWfs,88
|
56
|
+
pangea_sdk-5.2.1.dist-info/RECORD,,
|
@@ -1,75 +0,0 @@
|
|
1
|
-
from __future__ import annotations
|
2
|
-
|
3
|
-
from pangea.asyncio.services.base import ServiceBaseAsync
|
4
|
-
from pangea.config import PangeaConfig
|
5
|
-
from pangea.response import PangeaResponse
|
6
|
-
from pangea.services.ai_guard import TextGuardResult
|
7
|
-
|
8
|
-
|
9
|
-
class AIGuardAsync(ServiceBaseAsync):
|
10
|
-
"""AI Guard service client.
|
11
|
-
|
12
|
-
Provides methods to interact with Pangea's AI Guard service.
|
13
|
-
|
14
|
-
Examples:
|
15
|
-
from pangea import PangeaConfig
|
16
|
-
from pangea.asyncio.services import AIGuardAsync
|
17
|
-
|
18
|
-
config = PangeaConfig(domain="aws.us.pangea.cloud")
|
19
|
-
ai_guard = AIGuardAsync(token="pangea_token", config=config)
|
20
|
-
"""
|
21
|
-
|
22
|
-
service_name = "ai-guard"
|
23
|
-
|
24
|
-
def __init__(
|
25
|
-
self, token: str, config: PangeaConfig | None = None, logger_name: str = "pangea", config_id: str | None = None
|
26
|
-
) -> None:
|
27
|
-
"""
|
28
|
-
AI Guard service client.
|
29
|
-
|
30
|
-
Initializes a new AI Guard client.
|
31
|
-
|
32
|
-
Args:
|
33
|
-
token: Pangea API token.
|
34
|
-
config: Pangea service configuration.
|
35
|
-
logger_name: Logger name.
|
36
|
-
config_id: Configuration ID.
|
37
|
-
|
38
|
-
Examples:
|
39
|
-
from pangea import PangeaConfig
|
40
|
-
from pangea.asyncio.services import AIGuardAsync
|
41
|
-
|
42
|
-
config = PangeaConfig(domain="aws.us.pangea.cloud")
|
43
|
-
ai_guard = AIGuardAsync(token="pangea_token", config=config)
|
44
|
-
"""
|
45
|
-
|
46
|
-
super().__init__(token, config, logger_name, config_id)
|
47
|
-
|
48
|
-
async def guard_text(
|
49
|
-
self,
|
50
|
-
text: str,
|
51
|
-
*,
|
52
|
-
recipe: str = "pangea_prompt_guard",
|
53
|
-
debug: bool = False,
|
54
|
-
) -> PangeaResponse[TextGuardResult]:
|
55
|
-
"""
|
56
|
-
Text guard (Beta)
|
57
|
-
|
58
|
-
Guard text.
|
59
|
-
|
60
|
-
How to install a [Beta release](https://pangea.cloud/docs/sdk/python/#beta-releases).
|
61
|
-
|
62
|
-
OperationId: ai_guard_post_v1beta_text_guard
|
63
|
-
|
64
|
-
Args:
|
65
|
-
text: Text.
|
66
|
-
recipe: Recipe.
|
67
|
-
debug: Debug.
|
68
|
-
|
69
|
-
Examples:
|
70
|
-
response = await ai_guard.guard_text("text")
|
71
|
-
"""
|
72
|
-
|
73
|
-
return await self.request.post(
|
74
|
-
"v1beta/text/guard", TextGuardResult, data={"text": text, "recipe": recipe, "debug": debug}
|
75
|
-
)
|
@@ -1,73 +0,0 @@
|
|
1
|
-
from __future__ import annotations
|
2
|
-
|
3
|
-
from typing import TYPE_CHECKING
|
4
|
-
|
5
|
-
from pangea.asyncio.services.base import ServiceBaseAsync
|
6
|
-
from pangea.config import PangeaConfig
|
7
|
-
from pangea.services.prompt_guard import GuardResult, Message
|
8
|
-
|
9
|
-
if TYPE_CHECKING:
|
10
|
-
from collections.abc import Iterable
|
11
|
-
|
12
|
-
from pangea.response import PangeaResponse
|
13
|
-
|
14
|
-
|
15
|
-
class PromptGuardAsync(ServiceBaseAsync):
|
16
|
-
"""Prompt Guard service client.
|
17
|
-
|
18
|
-
Provides methods to interact with Pangea's Prompt Guard service.
|
19
|
-
|
20
|
-
Examples:
|
21
|
-
from pangea import PangeaConfig
|
22
|
-
from pangea.asyncio.services import PromptGuardAsync
|
23
|
-
|
24
|
-
config = PangeaConfig(domain="aws.us.pangea.cloud")
|
25
|
-
prompt_guard = PromptGuardAsync(token="pangea_token", config=config)
|
26
|
-
"""
|
27
|
-
|
28
|
-
service_name = "prompt-guard"
|
29
|
-
|
30
|
-
def __init__(
|
31
|
-
self, token: str, config: PangeaConfig | None = None, logger_name: str = "pangea", config_id: str | None = None
|
32
|
-
) -> None:
|
33
|
-
"""
|
34
|
-
Prompt Guard service client.
|
35
|
-
|
36
|
-
Initializes a new Prompt Guard client.
|
37
|
-
|
38
|
-
Args:
|
39
|
-
token: Pangea API token.
|
40
|
-
config: Pangea service configuration.
|
41
|
-
logger_name: Logger name.
|
42
|
-
config_id: Configuration ID.
|
43
|
-
|
44
|
-
Examples:
|
45
|
-
from pangea import PangeaConfig
|
46
|
-
from pangea.asyncio.services import PromptGuardAsync
|
47
|
-
|
48
|
-
config = PangeaConfig(domain="aws.us.pangea.cloud")
|
49
|
-
prompt_guard = PromptGuardAsync(token="pangea_token", config=config)
|
50
|
-
"""
|
51
|
-
|
52
|
-
super().__init__(token, config, logger_name, config_id)
|
53
|
-
|
54
|
-
async def guard(self, messages: Iterable[Message]) -> PangeaResponse[GuardResult]:
|
55
|
-
"""
|
56
|
-
Guard (Beta)
|
57
|
-
|
58
|
-
Guard messages.
|
59
|
-
|
60
|
-
How to install a [Beta release](https://pangea.cloud/docs/sdk/python/#beta-releases).
|
61
|
-
|
62
|
-
OperationId: prompt_guard_post_v1beta_guard
|
63
|
-
|
64
|
-
Args:
|
65
|
-
messages: Messages.
|
66
|
-
|
67
|
-
Examples:
|
68
|
-
from pangea.asyncio.services.prompt_guard import Message
|
69
|
-
|
70
|
-
response = await prompt_guard.guard([Message(role="user", content="hello world")])
|
71
|
-
"""
|
72
|
-
|
73
|
-
return await self.request.post("v1beta/guard", GuardResult, data={"messages": messages})
|
pangea/services/ai_guard.py
DELETED
@@ -1,157 +0,0 @@
|
|
1
|
-
from __future__ import annotations
|
2
|
-
|
3
|
-
from typing import List, Optional
|
4
|
-
|
5
|
-
from typing_extensions import Literal
|
6
|
-
|
7
|
-
from pangea.config import PangeaConfig
|
8
|
-
from pangea.response import PangeaResponse, PangeaResponseResult
|
9
|
-
from pangea.services.base import ServiceBase
|
10
|
-
from pangea.services.intel import UserBreachedData
|
11
|
-
|
12
|
-
|
13
|
-
class TextGuardSecurityIssues(PangeaResponseResult):
|
14
|
-
compromised_email_addresses: int
|
15
|
-
malicious_domain_count: int
|
16
|
-
malicious_ip_count: int
|
17
|
-
malicious_url_count: int
|
18
|
-
redact_rule_match_count: int
|
19
|
-
|
20
|
-
|
21
|
-
class TextGuardFindings(PangeaResponseResult):
|
22
|
-
artifact_count: Optional[int] = None
|
23
|
-
malicious_count: Optional[int] = None
|
24
|
-
security_issues: TextGuardSecurityIssues
|
25
|
-
|
26
|
-
|
27
|
-
class RedactRecognizerResult(PangeaResponseResult):
|
28
|
-
field_type: str
|
29
|
-
"""The entity name."""
|
30
|
-
|
31
|
-
score: float
|
32
|
-
"""The certainty score that the entity matches this specific snippet."""
|
33
|
-
|
34
|
-
text: str
|
35
|
-
"""The text snippet that matched."""
|
36
|
-
|
37
|
-
start: int
|
38
|
-
"""The starting index of a snippet."""
|
39
|
-
|
40
|
-
end: int
|
41
|
-
"""The ending index of a snippet."""
|
42
|
-
|
43
|
-
redacted: bool
|
44
|
-
"""Indicates if this rule was used to anonymize a text snippet."""
|
45
|
-
|
46
|
-
|
47
|
-
class RedactReport(PangeaResponseResult):
|
48
|
-
count: int
|
49
|
-
recognizer_results: List[RedactRecognizerResult]
|
50
|
-
|
51
|
-
|
52
|
-
class IntelResults(PangeaResponseResult):
|
53
|
-
category: List[str]
|
54
|
-
"""
|
55
|
-
The categories that apply to this indicator as determined by the provider.
|
56
|
-
"""
|
57
|
-
|
58
|
-
score: int
|
59
|
-
"""The score, given by the Pangea service, for the indicator."""
|
60
|
-
|
61
|
-
verdict: Literal["malicious", "suspicious", "unknown", "benign"]
|
62
|
-
|
63
|
-
|
64
|
-
class TextGuardReport(PangeaResponseResult):
|
65
|
-
domain_intel: Optional[IntelResults] = None
|
66
|
-
ip_intel: Optional[IntelResults] = None
|
67
|
-
redact: RedactReport
|
68
|
-
url_intel: Optional[IntelResults] = None
|
69
|
-
user_intel: Optional[UserBreachedData] = None
|
70
|
-
|
71
|
-
|
72
|
-
class TextGuardArtifact(PangeaResponseResult):
|
73
|
-
defanged: bool
|
74
|
-
end: int
|
75
|
-
start: int
|
76
|
-
type: str
|
77
|
-
value: str
|
78
|
-
verdict: Optional[str] = None
|
79
|
-
"""The verdict, given by the Pangea service, for the indicator."""
|
80
|
-
|
81
|
-
|
82
|
-
class TextGuardResult(PangeaResponseResult):
|
83
|
-
artifacts: Optional[List[TextGuardArtifact]] = None
|
84
|
-
findings: TextGuardFindings
|
85
|
-
redacted_prompt: str
|
86
|
-
|
87
|
-
# `debug=True` only.
|
88
|
-
report: Optional[TextGuardReport] = None
|
89
|
-
|
90
|
-
|
91
|
-
class AIGuard(ServiceBase):
|
92
|
-
"""AI Guard service client.
|
93
|
-
|
94
|
-
Provides methods to interact with Pangea's AI Guard service.
|
95
|
-
|
96
|
-
Examples:
|
97
|
-
from pangea import PangeaConfig
|
98
|
-
from pangea.services import AIGuard
|
99
|
-
|
100
|
-
config = PangeaConfig(domain="aws.us.pangea.cloud")
|
101
|
-
ai_guard = AIGuard(token="pangea_token", config=config)
|
102
|
-
"""
|
103
|
-
|
104
|
-
service_name = "ai-guard"
|
105
|
-
|
106
|
-
def __init__(
|
107
|
-
self, token: str, config: PangeaConfig | None = None, logger_name: str = "pangea", config_id: str | None = None
|
108
|
-
) -> None:
|
109
|
-
"""
|
110
|
-
AI Guard service client.
|
111
|
-
|
112
|
-
Initializes a new AI Guard client.
|
113
|
-
|
114
|
-
Args:
|
115
|
-
token: Pangea API token.
|
116
|
-
config: Pangea service configuration.
|
117
|
-
logger_name: Logger name.
|
118
|
-
config_id: Configuration ID.
|
119
|
-
|
120
|
-
Examples:
|
121
|
-
from pangea import PangeaConfig
|
122
|
-
from pangea.services import AIGuard
|
123
|
-
|
124
|
-
config = PangeaConfig(domain="aws.us.pangea.cloud")
|
125
|
-
ai_guard = AIGuard(token="pangea_token", config=config)
|
126
|
-
"""
|
127
|
-
|
128
|
-
super().__init__(token, config, logger_name, config_id)
|
129
|
-
|
130
|
-
def guard_text(
|
131
|
-
self,
|
132
|
-
text: str,
|
133
|
-
*,
|
134
|
-
recipe: str = "pangea_prompt_guard",
|
135
|
-
debug: bool = False,
|
136
|
-
) -> PangeaResponse[TextGuardResult]:
|
137
|
-
"""
|
138
|
-
Text guard (Beta)
|
139
|
-
|
140
|
-
Guard text.
|
141
|
-
|
142
|
-
How to install a [Beta release](https://pangea.cloud/docs/sdk/python/#beta-releases).
|
143
|
-
|
144
|
-
OperationId: ai_guard_post_v1beta_text_guard
|
145
|
-
|
146
|
-
Args:
|
147
|
-
text: Text.
|
148
|
-
recipe: Recipe.
|
149
|
-
debug: Debug.
|
150
|
-
|
151
|
-
Examples:
|
152
|
-
response = ai_guard.guard_text("text")
|
153
|
-
"""
|
154
|
-
|
155
|
-
return self.request.post(
|
156
|
-
"v1beta/text/guard", TextGuardResult, data={"text": text, "recipe": recipe, "debug": debug}
|
157
|
-
)
|
pangea/services/prompt_guard.py
DELETED
@@ -1,83 +0,0 @@
|
|
1
|
-
from __future__ import annotations
|
2
|
-
|
3
|
-
from typing import TYPE_CHECKING, Optional
|
4
|
-
|
5
|
-
from pangea.config import PangeaConfig
|
6
|
-
from pangea.response import APIRequestModel, PangeaResponse, PangeaResponseResult
|
7
|
-
from pangea.services.base import ServiceBase
|
8
|
-
|
9
|
-
if TYPE_CHECKING:
|
10
|
-
from collections.abc import Iterable
|
11
|
-
|
12
|
-
|
13
|
-
class Message(APIRequestModel):
|
14
|
-
role: str
|
15
|
-
content: str
|
16
|
-
|
17
|
-
|
18
|
-
class GuardResult(PangeaResponseResult):
|
19
|
-
detected: bool
|
20
|
-
type: Optional[str] = None
|
21
|
-
detector: Optional[str] = None
|
22
|
-
confidence: int
|
23
|
-
|
24
|
-
|
25
|
-
class PromptGuard(ServiceBase):
|
26
|
-
"""Prompt Guard service client.
|
27
|
-
|
28
|
-
Provides methods to interact with Pangea's Prompt Guard service.
|
29
|
-
|
30
|
-
Examples:
|
31
|
-
from pangea import PangeaConfig
|
32
|
-
from pangea.services import PromptGuard
|
33
|
-
|
34
|
-
config = PangeaConfig(domain="aws.us.pangea.cloud")
|
35
|
-
prompt_guard = PromptGuard(token="pangea_token", config=config)
|
36
|
-
"""
|
37
|
-
|
38
|
-
service_name = "prompt-guard"
|
39
|
-
|
40
|
-
def __init__(
|
41
|
-
self, token: str, config: PangeaConfig | None = None, logger_name: str = "pangea", config_id: str | None = None
|
42
|
-
) -> None:
|
43
|
-
"""
|
44
|
-
Prompt Guard service client.
|
45
|
-
|
46
|
-
Initializes a new Prompt Guard client.
|
47
|
-
|
48
|
-
Args:
|
49
|
-
token: Pangea API token.
|
50
|
-
config: Pangea service configuration.
|
51
|
-
logger_name: Logger name.
|
52
|
-
config_id: Configuration ID.
|
53
|
-
|
54
|
-
Examples:
|
55
|
-
from pangea import PangeaConfig
|
56
|
-
from pangea.services import PromptGuard
|
57
|
-
|
58
|
-
config = PangeaConfig(domain="aws.us.pangea.cloud")
|
59
|
-
prompt_guard = PromptGuard(token="pangea_token", config=config)
|
60
|
-
"""
|
61
|
-
|
62
|
-
super().__init__(token, config, logger_name, config_id)
|
63
|
-
|
64
|
-
def guard(self, messages: Iterable[Message]) -> PangeaResponse[GuardResult]:
|
65
|
-
"""
|
66
|
-
Guard (Beta)
|
67
|
-
|
68
|
-
Guard messages.
|
69
|
-
|
70
|
-
How to install a [Beta release](https://pangea.cloud/docs/sdk/python/#beta-releases).
|
71
|
-
|
72
|
-
OperationId: prompt_guard_post_v1beta_guard
|
73
|
-
|
74
|
-
Args:
|
75
|
-
messages: Messages.
|
76
|
-
|
77
|
-
Examples:
|
78
|
-
from pangea.services.prompt_guard import Message
|
79
|
-
|
80
|
-
response = prompt_guard.guard([Message(role="user", content="hello world")])
|
81
|
-
"""
|
82
|
-
|
83
|
-
return self.request.post("v1beta/guard", GuardResult, data={"messages": messages})
|
File without changes
|