pangea-sdk 5.2.0b1__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/audit.py +6 -10
- pangea/asyncio/services/authz.py +23 -2
- pangea/asyncio/services/base.py +21 -2
- 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 +16 -2
- 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/utils.py +8 -9
- {pangea_sdk-5.2.0b1.dist-info → pangea_sdk-5.2.1.dist-info}/METADATA +9 -8
- {pangea_sdk-5.2.0b1.dist-info → pangea_sdk-5.2.1.dist-info}/RECORD +24 -28
- pangea/asyncio/services/data_guard.py +0 -65
- pangea/asyncio/services/prompt_guard.py +0 -39
- pangea/services/data_guard.py +0 -147
- pangea/services/prompt_guard.py +0 -48
- {pangea_sdk-5.2.0b1.dist-info → pangea_sdk-5.2.1.dist-info}/WHEEL +0 -0
pangea/services/data_guard.py
DELETED
@@ -1,147 +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.response import PangeaResponse, PangeaResponseResult
|
8
|
-
from pangea.services.base import ServiceBase
|
9
|
-
from pangea.services.intel import UserBreachedData
|
10
|
-
|
11
|
-
|
12
|
-
class TextGuardSecurityIssues(PangeaResponseResult):
|
13
|
-
compromised_email_addresses: int
|
14
|
-
malicious_domain_count: int
|
15
|
-
malicious_ip_count: int
|
16
|
-
malicious_url_count: int
|
17
|
-
redacted_item_count: int
|
18
|
-
|
19
|
-
|
20
|
-
class TextGuardFindings(PangeaResponseResult):
|
21
|
-
artifact_count: int
|
22
|
-
malicious_count: int
|
23
|
-
security_issues: TextGuardSecurityIssues
|
24
|
-
|
25
|
-
|
26
|
-
class RedactRecognizerResult(PangeaResponseResult):
|
27
|
-
field_type: str
|
28
|
-
"""The entity name."""
|
29
|
-
|
30
|
-
score: float
|
31
|
-
"""The certainty score that the entity matches this specific snippet."""
|
32
|
-
|
33
|
-
text: str
|
34
|
-
"""The text snippet that matched."""
|
35
|
-
|
36
|
-
start: int
|
37
|
-
"""The starting index of a snippet."""
|
38
|
-
|
39
|
-
end: int
|
40
|
-
"""The ending index of a snippet."""
|
41
|
-
|
42
|
-
redacted: bool
|
43
|
-
"""Indicates if this rule was used to anonymize a text snippet."""
|
44
|
-
|
45
|
-
|
46
|
-
class RedactReport(PangeaResponseResult):
|
47
|
-
count: int
|
48
|
-
recognizer_results: List[RedactRecognizerResult]
|
49
|
-
|
50
|
-
|
51
|
-
class IntelResults(PangeaResponseResult):
|
52
|
-
category: List[str]
|
53
|
-
"""
|
54
|
-
The categories that apply to this indicator as determined by the provider.
|
55
|
-
"""
|
56
|
-
|
57
|
-
score: int
|
58
|
-
"""The score, given by the Pangea service, for the indicator."""
|
59
|
-
|
60
|
-
verdict: Literal["malicious", "suspicious", "unknown", "benign"]
|
61
|
-
|
62
|
-
|
63
|
-
class TextGuardReport(PangeaResponseResult):
|
64
|
-
domain_intel: Optional[IntelResults] = None
|
65
|
-
ip_intel: Optional[IntelResults] = None
|
66
|
-
redact: RedactReport
|
67
|
-
url_intel: Optional[IntelResults] = None
|
68
|
-
user_intel: Optional[UserBreachedData] = None
|
69
|
-
|
70
|
-
|
71
|
-
class TextGuardArtifact(PangeaResponseResult):
|
72
|
-
defanged: bool
|
73
|
-
end: int
|
74
|
-
start: int
|
75
|
-
type: str
|
76
|
-
value: str
|
77
|
-
verdict: Optional[str] = None
|
78
|
-
"""The verdict, given by the Pangea service, for the indicator."""
|
79
|
-
|
80
|
-
|
81
|
-
class TextGuardResult(PangeaResponseResult):
|
82
|
-
artifacts: Optional[List[TextGuardArtifact]] = None
|
83
|
-
findings: TextGuardFindings
|
84
|
-
redacted_prompt: str
|
85
|
-
|
86
|
-
# `debug=True` only.
|
87
|
-
report: Optional[TextGuardReport] = None
|
88
|
-
|
89
|
-
|
90
|
-
class DataGuard(ServiceBase):
|
91
|
-
"""Data Guard service client.
|
92
|
-
|
93
|
-
Provides methods to interact with Pangea's Data Guard service.
|
94
|
-
"""
|
95
|
-
|
96
|
-
service_name = "data-guard"
|
97
|
-
|
98
|
-
def guard_text(
|
99
|
-
self,
|
100
|
-
text: str,
|
101
|
-
*,
|
102
|
-
recipe: str = "pangea_prompt_guard",
|
103
|
-
debug: bool = False,
|
104
|
-
) -> PangeaResponse[TextGuardResult]:
|
105
|
-
"""
|
106
|
-
Text guard (Beta)
|
107
|
-
|
108
|
-
Guard text.
|
109
|
-
|
110
|
-
How to install a [Beta release](https://pangea.cloud/docs/sdk/python/#beta-releases).
|
111
|
-
|
112
|
-
OperationId: data_guard_post_v1_text_guard
|
113
|
-
|
114
|
-
Args:
|
115
|
-
text: Text.
|
116
|
-
recipe: Recipe.
|
117
|
-
debug: Debug.
|
118
|
-
|
119
|
-
Examples:
|
120
|
-
response = data_guard.guard_text("text")
|
121
|
-
"""
|
122
|
-
|
123
|
-
return self.request.post(
|
124
|
-
"v1/text/guard", TextGuardResult, data={"text": text, "recipe": recipe, "debug": debug}
|
125
|
-
)
|
126
|
-
|
127
|
-
def guard_file(
|
128
|
-
self,
|
129
|
-
file_url: str,
|
130
|
-
) -> PangeaResponse[PangeaResponseResult]:
|
131
|
-
"""
|
132
|
-
File guard (Beta)
|
133
|
-
|
134
|
-
Guard a file URL.
|
135
|
-
|
136
|
-
How to install a [Beta release](https://pangea.cloud/docs/sdk/python/#beta-releases).
|
137
|
-
|
138
|
-
OperationId: data_guard_post_v1_file_guard
|
139
|
-
|
140
|
-
Args:
|
141
|
-
file_url: File URL.
|
142
|
-
|
143
|
-
Examples:
|
144
|
-
response = data_guard.guard_file("https://example.org/file.txt")
|
145
|
-
"""
|
146
|
-
|
147
|
-
return self.request.post("v1/file/guard", PangeaResponseResult, data={"file_url": file_url})
|
pangea/services/prompt_guard.py
DELETED
@@ -1,48 +0,0 @@
|
|
1
|
-
from __future__ import annotations
|
2
|
-
|
3
|
-
from typing import TYPE_CHECKING, Optional
|
4
|
-
|
5
|
-
from pangea.response import APIRequestModel, PangeaResponse, PangeaResponseResult
|
6
|
-
from pangea.services.base import ServiceBase
|
7
|
-
|
8
|
-
if TYPE_CHECKING:
|
9
|
-
from collections.abc import Iterable
|
10
|
-
|
11
|
-
|
12
|
-
class Message(APIRequestModel):
|
13
|
-
role: str
|
14
|
-
content: str
|
15
|
-
|
16
|
-
|
17
|
-
class GuardResult(PangeaResponseResult):
|
18
|
-
prompt_injection_detected: bool
|
19
|
-
prompt_injection_type: Optional[str] = None
|
20
|
-
prompt_injection_detector: Optional[str] = None
|
21
|
-
|
22
|
-
|
23
|
-
class PromptGuard(ServiceBase):
|
24
|
-
"""Prompt Guard service client.
|
25
|
-
|
26
|
-
Provides methods to interact with Pangea's Prompt Guard service.
|
27
|
-
"""
|
28
|
-
|
29
|
-
service_name = "prompt-guard"
|
30
|
-
|
31
|
-
def guard(self, messages: Iterable[Message]) -> PangeaResponse[GuardResult]:
|
32
|
-
"""
|
33
|
-
Guard (Beta)
|
34
|
-
|
35
|
-
Guard messages.
|
36
|
-
|
37
|
-
How to install a [Beta release](https://pangea.cloud/docs/sdk/python/#beta-releases).
|
38
|
-
|
39
|
-
OperationId: prompt_guard_post_v1_guard
|
40
|
-
|
41
|
-
Args:
|
42
|
-
messages: Messages.
|
43
|
-
|
44
|
-
Examples:
|
45
|
-
response = prompt_guard.guard([Message(role="user", content="hello world")])
|
46
|
-
"""
|
47
|
-
|
48
|
-
return self.request.post("v1/guard", GuardResult, data={"messages": messages})
|
File without changes
|