pangea-sdk 6.5.0b1__py3-none-any.whl → 6.6.0__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 +3 -11
- pangea/_constants.py +4 -0
- pangea/_typing.py +30 -0
- pangea/asyncio/__init__.py +2 -1
- pangea/asyncio/file_uploader.py +3 -2
- pangea/asyncio/request.py +66 -162
- pangea/asyncio/services/__init__.py +19 -3
- pangea/asyncio/services/ai_guard.py +23 -169
- pangea/asyncio/services/audit.py +1 -301
- pangea/asyncio/services/authn.py +25 -8
- pangea/asyncio/services/base.py +21 -6
- pangea/asyncio/services/file_scan.py +1 -1
- pangea/asyncio/services/intel.py +160 -95
- pangea/asyncio/services/prompt_guard.py +5 -112
- pangea/asyncio/services/redact.py +4 -265
- pangea/config.py +4 -2
- pangea/file_uploader.py +4 -1
- pangea/request.py +91 -166
- pangea/response.py +5 -1
- pangea/services/__init__.py +19 -3
- pangea/services/ai_guard.py +84 -694
- pangea/services/audit/audit.py +3 -301
- pangea/services/audit/models.py +1 -273
- pangea/services/audit/util.py +2 -0
- pangea/services/authn/authn.py +4 -5
- pangea/services/base.py +3 -0
- pangea/services/file_scan.py +3 -2
- pangea/services/intel.py +187 -252
- pangea/services/prompt_guard.py +5 -193
- pangea/services/redact.py +7 -473
- pangea/services/vault/vault.py +3 -0
- {pangea_sdk-6.5.0b1.dist-info → pangea_sdk-6.6.0.dist-info}/METADATA +17 -18
- pangea_sdk-6.6.0.dist-info/RECORD +62 -0
- pangea_sdk-6.6.0.dist-info/WHEEL +4 -0
- pangea/asyncio/services/management.py +0 -576
- pangea/services/management.py +0 -720
- pangea_sdk-6.5.0b1.dist-info/RECORD +0 -62
- pangea_sdk-6.5.0b1.dist-info/WHEEL +0 -4
pangea/services/prompt_guard.py
CHANGED
@@ -1,18 +1,18 @@
|
|
1
1
|
from __future__ import annotations
|
2
2
|
|
3
|
-
from
|
4
|
-
from typing import TYPE_CHECKING, Annotated, Literal, Optional
|
5
|
-
|
6
|
-
from pydantic import BaseModel, Field
|
3
|
+
from typing import TYPE_CHECKING, Literal, Optional
|
7
4
|
|
8
5
|
from pangea.config import PangeaConfig
|
9
|
-
from pangea.response import APIRequestModel, APIResponseModel,
|
6
|
+
from pangea.response import APIRequestModel, APIResponseModel, PangeaResponse, PangeaResponseResult
|
10
7
|
from pangea.services.base import ServiceBase
|
11
8
|
|
12
9
|
if TYPE_CHECKING:
|
13
10
|
from collections.abc import Iterable
|
14
11
|
|
15
12
|
|
13
|
+
__all__ = ("Message", "PromptGuard")
|
14
|
+
|
15
|
+
|
16
16
|
class Message(APIRequestModel):
|
17
17
|
role: str
|
18
18
|
content: str
|
@@ -49,92 +49,6 @@ class GuardResult(PangeaResponseResult):
|
|
49
49
|
"""List of classification results with labels and confidence scores"""
|
50
50
|
|
51
51
|
|
52
|
-
class Areas(BaseModel):
|
53
|
-
malicious_prompt: Optional[bool] = None
|
54
|
-
benign_prompt: Optional[bool] = None
|
55
|
-
|
56
|
-
|
57
|
-
class AuditDataActivityConfig(BaseModel):
|
58
|
-
enabled: bool
|
59
|
-
audit_service_config_id: str
|
60
|
-
areas: Areas
|
61
|
-
|
62
|
-
|
63
|
-
class ServiceConfig(BaseModel):
|
64
|
-
id: Optional[str] = None
|
65
|
-
version: Optional[str] = None
|
66
|
-
analyzers: Optional[dict[str, bool]] = None
|
67
|
-
malicious_detection_threshold: Annotated[Optional[float], Field(ge=0.0, le=1.0)] = None
|
68
|
-
benign_detection_threshold: Annotated[Optional[float], Field(ge=0.0, le=1.0)] = None
|
69
|
-
audit_data_activity: Optional[AuditDataActivityConfig] = None
|
70
|
-
|
71
|
-
|
72
|
-
class ServiceConfigFilter(BaseModel):
|
73
|
-
id: Optional[str] = None
|
74
|
-
"""
|
75
|
-
Only records where id equals this value.
|
76
|
-
"""
|
77
|
-
id__contains: Optional[list[str]] = None
|
78
|
-
"""
|
79
|
-
Only records where id includes each substring.
|
80
|
-
"""
|
81
|
-
id__in: Optional[list[str]] = None
|
82
|
-
"""
|
83
|
-
Only records where id equals one of the provided substrings.
|
84
|
-
"""
|
85
|
-
created_at: Optional[PangeaDateTime] = None
|
86
|
-
"""
|
87
|
-
Only records where created_at equals this value.
|
88
|
-
"""
|
89
|
-
created_at__gt: Optional[PangeaDateTime] = None
|
90
|
-
"""
|
91
|
-
Only records where created_at is greater than this value.
|
92
|
-
"""
|
93
|
-
created_at__gte: Optional[PangeaDateTime] = None
|
94
|
-
"""
|
95
|
-
Only records where created_at is greater than or equal to this value.
|
96
|
-
"""
|
97
|
-
created_at__lt: Optional[PangeaDateTime] = None
|
98
|
-
"""
|
99
|
-
Only records where created_at is less than this value.
|
100
|
-
"""
|
101
|
-
created_at__lte: Optional[PangeaDateTime] = None
|
102
|
-
"""
|
103
|
-
Only records where created_at is less than or equal to this value.
|
104
|
-
"""
|
105
|
-
updated_at: Optional[PangeaDateTime] = None
|
106
|
-
"""
|
107
|
-
Only records where updated_at equals this value.
|
108
|
-
"""
|
109
|
-
updated_at__gt: Optional[PangeaDateTime] = None
|
110
|
-
"""
|
111
|
-
Only records where updated_at is greater than this value.
|
112
|
-
"""
|
113
|
-
updated_at__gte: Optional[PangeaDateTime] = None
|
114
|
-
"""
|
115
|
-
Only records where updated_at is greater than or equal to this value.
|
116
|
-
"""
|
117
|
-
updated_at__lt: Optional[PangeaDateTime] = None
|
118
|
-
"""
|
119
|
-
Only records where updated_at is less than this value.
|
120
|
-
"""
|
121
|
-
updated_at__lte: Optional[PangeaDateTime] = None
|
122
|
-
"""
|
123
|
-
Only records where updated_at is less than or equal to this value.
|
124
|
-
"""
|
125
|
-
|
126
|
-
|
127
|
-
class ServiceConfigsPage(PangeaResponseResult):
|
128
|
-
count: Optional[int] = None
|
129
|
-
"""The total number of service configs matched by the list request."""
|
130
|
-
last: Optional[str] = None
|
131
|
-
"""
|
132
|
-
Used to fetch the next page of the current listing when provided in a
|
133
|
-
repeated request's last parameter.
|
134
|
-
"""
|
135
|
-
items: Optional[list[ServiceConfig]] = None
|
136
|
-
|
137
|
-
|
138
52
|
class PromptGuard(ServiceBase):
|
139
53
|
"""Prompt Guard service client.
|
140
54
|
|
@@ -205,105 +119,3 @@ class PromptGuard(ServiceBase):
|
|
205
119
|
GuardResult,
|
206
120
|
data={"messages": messages, "analyzers": analyzers, "classify": classify},
|
207
121
|
)
|
208
|
-
|
209
|
-
def get_service_config(
|
210
|
-
self,
|
211
|
-
*,
|
212
|
-
id: str | None = None,
|
213
|
-
version: str | None = None,
|
214
|
-
analyzers: Mapping[str, bool] | None = None,
|
215
|
-
malicious_detection_threshold: float | None = None,
|
216
|
-
benign_detection_threshold: float | None = None,
|
217
|
-
audit_data_activity: AuditDataActivityConfig | None = None,
|
218
|
-
) -> PangeaResponse[PangeaResponseResult]:
|
219
|
-
"""
|
220
|
-
OperationId: prompt_guard_post_v1beta_config
|
221
|
-
"""
|
222
|
-
return self.request.post(
|
223
|
-
"v1beta/config",
|
224
|
-
data={
|
225
|
-
"id": id,
|
226
|
-
"version": version,
|
227
|
-
"analyzers": analyzers,
|
228
|
-
"malicious_detection_threshold": malicious_detection_threshold,
|
229
|
-
"benign_detection_threshold": benign_detection_threshold,
|
230
|
-
"audit_data_activity": audit_data_activity,
|
231
|
-
},
|
232
|
-
result_class=PangeaResponseResult,
|
233
|
-
)
|
234
|
-
|
235
|
-
def create_service_config(
|
236
|
-
self,
|
237
|
-
*,
|
238
|
-
id: str | None = None,
|
239
|
-
version: str | None = None,
|
240
|
-
analyzers: Mapping[str, bool] | None = None,
|
241
|
-
malicious_detection_threshold: float | None = None,
|
242
|
-
benign_detection_threshold: float | None = None,
|
243
|
-
audit_data_activity: AuditDataActivityConfig | None = None,
|
244
|
-
) -> PangeaResponse[PangeaResponseResult]:
|
245
|
-
"""
|
246
|
-
OperationId: prompt_guard_post_v1beta_config_create
|
247
|
-
"""
|
248
|
-
return self.request.post(
|
249
|
-
"v1beta/config/create",
|
250
|
-
data={
|
251
|
-
"id": id,
|
252
|
-
"version": version,
|
253
|
-
"analyzers": analyzers,
|
254
|
-
"malicious_detection_threshold": malicious_detection_threshold,
|
255
|
-
"benign_detection_threshold": benign_detection_threshold,
|
256
|
-
"audit_data_activity": audit_data_activity,
|
257
|
-
},
|
258
|
-
result_class=PangeaResponseResult,
|
259
|
-
)
|
260
|
-
|
261
|
-
def update_service_config(
|
262
|
-
self,
|
263
|
-
*,
|
264
|
-
id: str | None = None,
|
265
|
-
version: str | None = None,
|
266
|
-
analyzers: Mapping[str, bool] | None = None,
|
267
|
-
malicious_detection_threshold: float | None = None,
|
268
|
-
benign_detection_threshold: float | None = None,
|
269
|
-
audit_data_activity: AuditDataActivityConfig | None = None,
|
270
|
-
) -> PangeaResponse[PangeaResponseResult]:
|
271
|
-
"""
|
272
|
-
OperationId: prompt_guard_post_v1beta_config_update
|
273
|
-
"""
|
274
|
-
return self.request.post(
|
275
|
-
"v1beta/config/update",
|
276
|
-
data={
|
277
|
-
"id": id,
|
278
|
-
"version": version,
|
279
|
-
"analyzers": analyzers,
|
280
|
-
"malicious_detection_threshold": malicious_detection_threshold,
|
281
|
-
"benign_detection_threshold": benign_detection_threshold,
|
282
|
-
"audit_data_activity": audit_data_activity,
|
283
|
-
},
|
284
|
-
result_class=PangeaResponseResult,
|
285
|
-
)
|
286
|
-
|
287
|
-
def delete_service_config(self, id: str) -> PangeaResponse[PangeaResponseResult]:
|
288
|
-
"""
|
289
|
-
OperationId: prompt_guard_post_v1beta_config_delete
|
290
|
-
"""
|
291
|
-
return self.request.post("v1beta/config/delete", data={"id": id}, result_class=PangeaResponseResult)
|
292
|
-
|
293
|
-
def list_service_configs(
|
294
|
-
self,
|
295
|
-
*,
|
296
|
-
filter: ServiceConfigFilter | None = None,
|
297
|
-
last: str | None = None,
|
298
|
-
order: Literal["asc", "desc"] | None = None,
|
299
|
-
order_by: Literal["id", "created_at", "updated_at"] | None = None,
|
300
|
-
size: int | None = None,
|
301
|
-
) -> PangeaResponse[ServiceConfigsPage]:
|
302
|
-
"""
|
303
|
-
OperationId: prompt_guard_post_v1beta_config_list
|
304
|
-
"""
|
305
|
-
return self.request.post(
|
306
|
-
"v1beta/config/list",
|
307
|
-
data={"filter": filter, "last": last, "order": order, "order_by": order_by, "size": size},
|
308
|
-
result_class=ServiceConfigsPage,
|
309
|
-
)
|