pangea-sdk 5.4.0b1__py3-none-any.whl → 5.4.0b2__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 CHANGED
@@ -1,4 +1,4 @@
1
- __version__ = "5.4.0beta1"
1
+ __version__ = "5.4.0beta2"
2
2
 
3
3
  from pangea.asyncio.request import PangeaRequestAsync
4
4
  from pangea.config import PangeaConfig
pangea/asyncio/request.py CHANGED
@@ -53,6 +53,10 @@ class PangeaRequestAsync(PangeaRequestBase):
53
53
  if isinstance(data, BaseModel):
54
54
  data = data.model_dump(exclude_none=True)
55
55
 
56
+ if isinstance(data, dict):
57
+ # Remove `None` values.
58
+ data = {k: v for k, v in data.items() if v is not None}
59
+
56
60
  if data is None:
57
61
  data = {}
58
62
 
@@ -51,7 +51,9 @@ class PromptGuardAsync(ServiceBaseAsync):
51
51
 
52
52
  super().__init__(token, config, logger_name, config_id)
53
53
 
54
- async def guard(self, messages: Iterable[Message]) -> PangeaResponse[GuardResult]:
54
+ async def guard(
55
+ self, messages: Iterable[Message], *, analyzers: Iterable[str] | None = None
56
+ ) -> PangeaResponse[GuardResult]:
55
57
  """
56
58
  Guard (Beta)
57
59
 
@@ -63,6 +65,7 @@ class PromptGuardAsync(ServiceBaseAsync):
63
65
 
64
66
  Args:
65
67
  messages: Messages.
68
+ analyzers: Specific analyzers to be used in the call.
66
69
 
67
70
  Examples:
68
71
  from pangea.asyncio.services.prompt_guard import Message
@@ -70,4 +73,4 @@ class PromptGuardAsync(ServiceBaseAsync):
70
73
  response = await prompt_guard.guard([Message(role="user", content="hello world")])
71
74
  """
72
75
 
73
- return await self.request.post("v1beta/guard", GuardResult, data={"messages": messages})
76
+ return await self.request.post("v1beta/guard", GuardResult, data={"messages": messages, "analyzers": analyzers})
pangea/request.py CHANGED
@@ -230,6 +230,10 @@ class PangeaRequest(PangeaRequestBase):
230
230
  if isinstance(data, BaseModel):
231
231
  data = data.model_dump(exclude_none=True)
232
232
 
233
+ if isinstance(data, dict):
234
+ # Remove `None` values.
235
+ data = {k: v for k, v in data.items() if v is not None}
236
+
233
237
  if data is None:
234
238
  data = {}
235
239
 
@@ -1,9 +1,9 @@
1
1
  from __future__ import annotations
2
2
 
3
- from typing import TYPE_CHECKING, Optional
3
+ from typing import TYPE_CHECKING, Literal, Optional
4
4
 
5
5
  from pangea.config import PangeaConfig
6
- from pangea.response import APIRequestModel, PangeaResponse, PangeaResponseResult
6
+ from pangea.response import APIRequestModel, APIResponseModel, PangeaResponse, PangeaResponseResult
7
7
  from pangea.services.base import ServiceBase
8
8
 
9
9
  if TYPE_CHECKING:
@@ -15,11 +15,35 @@ class Message(APIRequestModel):
15
15
  content: str
16
16
 
17
17
 
18
+ class Classification(APIResponseModel):
19
+ category: str
20
+ """Classification category"""
21
+
22
+ label: str
23
+ """Classification label"""
24
+
25
+ confidence: float
26
+ """Confidence score for the classification"""
27
+
28
+
18
29
  class GuardResult(PangeaResponseResult):
19
30
  detected: bool
20
- type: Optional[str] = None
21
- detector: Optional[str] = None
31
+ """Boolean response for if the prompt was considered malicious or not"""
32
+
33
+ type: Optional[Literal["direct", "indirect"]] = None
34
+ """Type of analysis, either direct or indirect"""
35
+
36
+ analyzer: Optional[str] = None
37
+ """Prompt Analyzers for identifying and rejecting properties of prompts"""
38
+
22
39
  confidence: int
40
+ """Percent of confidence in the detection result, ranging from 0 to 100"""
41
+
42
+ info: Optional[str] = None
43
+ """Extra information about the detection result"""
44
+
45
+ classifications: list[Classification]
46
+ """List of classification results with labels and confidence scores"""
23
47
 
24
48
 
25
49
  class PromptGuard(ServiceBase):
@@ -61,7 +85,9 @@ class PromptGuard(ServiceBase):
61
85
 
62
86
  super().__init__(token, config, logger_name, config_id)
63
87
 
64
- def guard(self, messages: Iterable[Message]) -> PangeaResponse[GuardResult]:
88
+ def guard(
89
+ self, messages: Iterable[Message], *, analyzers: Iterable[str] | None = None
90
+ ) -> PangeaResponse[GuardResult]:
65
91
  """
66
92
  Guard (Beta)
67
93
 
@@ -72,7 +98,8 @@ class PromptGuard(ServiceBase):
72
98
  OperationId: prompt_guard_post_v1beta_guard
73
99
 
74
100
  Args:
75
- messages: Messages.
101
+ messages: Prompt content and role array.
102
+ analyzers: Specific analyzers to be used in the call.
76
103
 
77
104
  Examples:
78
105
  from pangea.services.prompt_guard import Message
@@ -80,4 +107,4 @@ class PromptGuard(ServiceBase):
80
107
  response = prompt_guard.guard([Message(role="user", content="hello world")])
81
108
  """
82
109
 
83
- return self.request.post("v1beta/guard", GuardResult, data={"messages": messages})
110
+ return self.request.post("v1beta/guard", GuardResult, data={"messages": messages, "analyzers": analyzers})
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: pangea-sdk
3
- Version: 5.4.0b1
3
+ Version: 5.4.0b2
4
4
  Summary: Pangea API SDK
5
5
  License: MIT
6
6
  Keywords: Pangea,SDK,Audit
@@ -63,13 +63,13 @@ the same compatibility guarantees as stable releases.
63
63
  Via pip:
64
64
 
65
65
  ```bash
66
- $ pip3 install pangea-sdk==5.4.0b1
66
+ $ pip3 install pangea-sdk==5.4.0b2
67
67
  ```
68
68
 
69
69
  Via poetry:
70
70
 
71
71
  ```bash
72
- $ poetry add pangea-sdk==5.4.0b1
72
+ $ poetry add pangea-sdk==5.4.0b2
73
73
  ```
74
74
 
75
75
  ## Usage
@@ -1,7 +1,7 @@
1
- pangea/__init__.py,sha256=5GVWxTAjdvD4yfQsWwkX4JBF9NJnedj3Xos107reJy0,251
1
+ pangea/__init__.py,sha256=D6T0FmtXtWk1W0BXPe9snPKzeo-dOtTEQHD3z5tFfxk,251
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=e-_wpOGsOLGlC4BXI6WBa_MFzkUoaMQEqYgXWaqoXQk,17900
4
+ pangea/asyncio/request.py,sha256=lpLY-o405r3-VUfrAE5uxYxI8UjM4hjPqUzAUtOGE5o,18040
5
5
  pangea/asyncio/services/__init__.py,sha256=L6Tdhjfx_ZECHskhLMPaCcOefi-r-imw6q_zlU4j-FY,464
6
6
  pangea/asyncio/services/ai_guard.py,sha256=FxO8GRBztfOhpd7Kzj4-jWAiG0kb89-jVWL_AnbEou8,2142
7
7
  pangea/asyncio/services/audit.py,sha256=rPaCx4cMzj-g9WFMRIysFCJAz6Btp6YrhcKe_exky8k,26283
@@ -11,7 +11,7 @@ pangea/asyncio/services/base.py,sha256=vRFVcO_uEAGJte3OUUBLD43RoiiFB1vC7SPyN6yEM
11
11
  pangea/asyncio/services/embargo.py,sha256=ctzj3kip6xos-Eu3JuOskrCGYC8T3JlsgAopZHiPSXM,3068
12
12
  pangea/asyncio/services/file_scan.py,sha256=PLG1O-PL4Yk9uY9D6NbMrZ5LHg70Z311s7bFe46UMZA,7108
13
13
  pangea/asyncio/services/intel.py,sha256=BcxGKSoZ1nJiEHyZM9yOwKSSPJUrB6ibJ19KR27VlgQ,40261
14
- pangea/asyncio/services/prompt_guard.py,sha256=gRh7Z-ZS21EN8vXXnK1OJ5kYvmOWxKppia8tZYeuhmM,2202
14
+ pangea/asyncio/services/prompt_guard.py,sha256=KMScsVybwQEwipN7CaC4AX4KRqlIkC8xZ2j7m-BDL9E,2349
15
15
  pangea/asyncio/services/redact.py,sha256=JPJcmeKFloMZRpkjAHAZbpZJpO993WsTfEwA-S5ov18,7951
16
16
  pangea/asyncio/services/sanitize.py,sha256=EbSdq_v9yZWce9xEYWvZharE9bJcxw8cg5Pv8LVxdxc,8627
17
17
  pangea/asyncio/services/share.py,sha256=AXXtFtmbXud0dAAom7qqHVOK9zBfX5S10MFS_1DQvio,30767
@@ -25,7 +25,7 @@ pangea/dump_audit.py,sha256=IevqaUUh7GDepdIW7slSxeZbkPrWIVbcX3sr4DgpJXI,7090
25
25
  pangea/exceptions.py,sha256=OBtzUECpNa6vNp8ySkHC-tm4QjFRCOAHBkMHqzAlOu8,5656
26
26
  pangea/file_uploader.py,sha256=4RQ44xt-faApC61nn2PlwHT7XYrJ4GeQA8Ug4tySEAg,1227
27
27
  pangea/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
28
- pangea/request.py,sha256=Xv2aWAmDBZ3oasIEMCHulsnXjAGzqubYTf3vRCcX2es,24942
28
+ pangea/request.py,sha256=vGB8owXUiNQoeiiACFvfXvg44JJo_L6WfcHlF6ug8co,25082
29
29
  pangea/response.py,sha256=lPAcYsF9Xg166CiyhCofVmQA-W4jevh0MQXxUa8Re68,7737
30
30
  pangea/services/__init__.py,sha256=h36HzyIGaI5kO6l3UCwKHx_Kd-m_9mYVwn5MLRVzblI,408
31
31
  pangea/services/ai_guard.py,sha256=-Ztyf9WUo1EB-gRzVH--OU62xzPoeVQ7BiFMTGUK5fI,3303
@@ -41,7 +41,7 @@ pangea/services/base.py,sha256=43pWQcR9CeT4sGzgctF3Sy4M_h7DaUzkuZD2Z7CcDUU,3845
41
41
  pangea/services/embargo.py,sha256=9Wfku4td5ORaIENKmnGmS5jxJJIRfWp6Q51L36Jsy0I,3897
42
42
  pangea/services/file_scan.py,sha256=QiO80uKqB_BnAOiYQKznXfxpa5j40qqETE3-zBRT_QE,7813
43
43
  pangea/services/intel.py,sha256=y1EX2ctYIxQc52lmHp6-Q_UIDM--t3fOpXDssWiRPfo,56474
44
- pangea/services/prompt_guard.py,sha256=baaYbYW_HoZJNB8NCIxxFjvJelqrl9UOtWa10-N1jgg,2312
44
+ pangea/services/prompt_guard.py,sha256=k-b8ukyXaHruqC4S2NjFKhDLcvY5Wp8Ga0g_Ep3WFKY,3244
45
45
  pangea/services/redact.py,sha256=ovIcT0jkXe57O7keGzSClWNCic8y-4NZoemXoSKjjww,12913
46
46
  pangea/services/sanitize.py,sha256=eAN1HhObiKqygy6HHcfl0NmxYfPMvqSKepwEAVVIIEE,12936
47
47
  pangea/services/share/file_format.py,sha256=1svO1ee_aenA9zoO_AaU-Rk5Ulp7kcPOc_KwNoluyQE,2797
@@ -55,6 +55,6 @@ pangea/services/vault/vault.py,sha256=ow-Zm7PYzfWIfUcA4UNnpeL2DHfZM4C7inRDmNR3zQ
55
55
  pangea/tools.py,sha256=2-Y4SAHWFv6Ocj42J_bWrVy27M5G3wi7a8LJn0dabHc,6427
56
56
  pangea/utils.py,sha256=dZ6MwFVEWXUgXvvDg-k6JnvVfsgslvtaBd7ez7afrqk,4983
57
57
  pangea/verify_audit.py,sha256=nSP17OzoSPdvezRExwfcf45H8ZPZnxZu-CbEp3qFJO0,17354
58
- pangea_sdk-5.4.0b1.dist-info/METADATA,sha256=7kHpv2AVDGKa_KQJSTv5dZa1TlvM4VC1_bpddpL5o1M,6843
59
- pangea_sdk-5.4.0b1.dist-info/WHEEL,sha256=IYZQI976HJqqOpQU6PHkJ8fb3tMNBFjg-Cn-pwAbaFM,88
60
- pangea_sdk-5.4.0b1.dist-info/RECORD,,
58
+ pangea_sdk-5.4.0b2.dist-info/METADATA,sha256=7_vZ3tIafJ9-TdGTZphBcqHo0MQPqp-bNb4L870CwgU,6843
59
+ pangea_sdk-5.4.0b2.dist-info/WHEEL,sha256=IYZQI976HJqqOpQU6PHkJ8fb3tMNBFjg-Cn-pwAbaFM,88
60
+ pangea_sdk-5.4.0b2.dist-info/RECORD,,