pangea-sdk 6.6.0__tar.gz → 6.8.0__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.
Files changed (62) hide show
  1. {pangea_sdk-6.6.0 → pangea_sdk-6.8.0}/PKG-INFO +5 -5
  2. {pangea_sdk-6.6.0 → pangea_sdk-6.8.0}/pangea/__init__.py +1 -1
  3. {pangea_sdk-6.6.0 → pangea_sdk-6.8.0}/pangea/asyncio/services/ai_guard.py +81 -1
  4. {pangea_sdk-6.6.0 → pangea_sdk-6.8.0}/pangea/asyncio/services/prompt_guard.py +2 -1
  5. {pangea_sdk-6.6.0 → pangea_sdk-6.8.0}/pangea/services/ai_guard.py +218 -17
  6. {pangea_sdk-6.6.0 → pangea_sdk-6.8.0}/pangea/services/prompt_guard.py +9 -7
  7. {pangea_sdk-6.6.0 → pangea_sdk-6.8.0}/pyproject.toml +10 -10
  8. {pangea_sdk-6.6.0 → pangea_sdk-6.8.0}/README.md +0 -0
  9. {pangea_sdk-6.6.0 → pangea_sdk-6.8.0}/pangea/_constants.py +0 -0
  10. {pangea_sdk-6.6.0 → pangea_sdk-6.8.0}/pangea/_typing.py +0 -0
  11. {pangea_sdk-6.6.0 → pangea_sdk-6.8.0}/pangea/asyncio/__init__.py +0 -0
  12. {pangea_sdk-6.6.0 → pangea_sdk-6.8.0}/pangea/asyncio/file_uploader.py +0 -0
  13. {pangea_sdk-6.6.0 → pangea_sdk-6.8.0}/pangea/asyncio/request.py +0 -0
  14. {pangea_sdk-6.6.0 → pangea_sdk-6.8.0}/pangea/asyncio/services/__init__.py +0 -0
  15. {pangea_sdk-6.6.0 → pangea_sdk-6.8.0}/pangea/asyncio/services/audit.py +0 -0
  16. {pangea_sdk-6.6.0 → pangea_sdk-6.8.0}/pangea/asyncio/services/authn.py +0 -0
  17. {pangea_sdk-6.6.0 → pangea_sdk-6.8.0}/pangea/asyncio/services/authz.py +0 -0
  18. {pangea_sdk-6.6.0 → pangea_sdk-6.8.0}/pangea/asyncio/services/base.py +0 -0
  19. {pangea_sdk-6.6.0 → pangea_sdk-6.8.0}/pangea/asyncio/services/embargo.py +0 -0
  20. {pangea_sdk-6.6.0 → pangea_sdk-6.8.0}/pangea/asyncio/services/file_scan.py +0 -0
  21. {pangea_sdk-6.6.0 → pangea_sdk-6.8.0}/pangea/asyncio/services/intel.py +0 -0
  22. {pangea_sdk-6.6.0 → pangea_sdk-6.8.0}/pangea/asyncio/services/redact.py +0 -0
  23. {pangea_sdk-6.6.0 → pangea_sdk-6.8.0}/pangea/asyncio/services/sanitize.py +0 -0
  24. {pangea_sdk-6.6.0 → pangea_sdk-6.8.0}/pangea/asyncio/services/share.py +0 -0
  25. {pangea_sdk-6.6.0 → pangea_sdk-6.8.0}/pangea/asyncio/services/vault.py +0 -0
  26. {pangea_sdk-6.6.0 → pangea_sdk-6.8.0}/pangea/audit_logger.py +0 -0
  27. {pangea_sdk-6.6.0 → pangea_sdk-6.8.0}/pangea/config.py +0 -0
  28. {pangea_sdk-6.6.0 → pangea_sdk-6.8.0}/pangea/crypto/rsa.py +0 -0
  29. {pangea_sdk-6.6.0 → pangea_sdk-6.8.0}/pangea/deep_verify.py +0 -0
  30. {pangea_sdk-6.6.0 → pangea_sdk-6.8.0}/pangea/deprecated.py +0 -0
  31. {pangea_sdk-6.6.0 → pangea_sdk-6.8.0}/pangea/dump_audit.py +0 -0
  32. {pangea_sdk-6.6.0 → pangea_sdk-6.8.0}/pangea/exceptions.py +0 -0
  33. {pangea_sdk-6.6.0 → pangea_sdk-6.8.0}/pangea/file_uploader.py +0 -0
  34. {pangea_sdk-6.6.0 → pangea_sdk-6.8.0}/pangea/py.typed +0 -0
  35. {pangea_sdk-6.6.0 → pangea_sdk-6.8.0}/pangea/request.py +0 -0
  36. {pangea_sdk-6.6.0 → pangea_sdk-6.8.0}/pangea/response.py +0 -0
  37. {pangea_sdk-6.6.0 → pangea_sdk-6.8.0}/pangea/services/__init__.py +0 -0
  38. {pangea_sdk-6.6.0 → pangea_sdk-6.8.0}/pangea/services/audit/audit.py +0 -0
  39. {pangea_sdk-6.6.0 → pangea_sdk-6.8.0}/pangea/services/audit/exceptions.py +0 -0
  40. {pangea_sdk-6.6.0 → pangea_sdk-6.8.0}/pangea/services/audit/models.py +0 -0
  41. {pangea_sdk-6.6.0 → pangea_sdk-6.8.0}/pangea/services/audit/signing.py +0 -0
  42. {pangea_sdk-6.6.0 → pangea_sdk-6.8.0}/pangea/services/audit/util.py +0 -0
  43. {pangea_sdk-6.6.0 → pangea_sdk-6.8.0}/pangea/services/authn/authn.py +0 -0
  44. {pangea_sdk-6.6.0 → pangea_sdk-6.8.0}/pangea/services/authn/models.py +0 -0
  45. {pangea_sdk-6.6.0 → pangea_sdk-6.8.0}/pangea/services/authz.py +0 -0
  46. {pangea_sdk-6.6.0 → pangea_sdk-6.8.0}/pangea/services/base.py +0 -0
  47. {pangea_sdk-6.6.0 → pangea_sdk-6.8.0}/pangea/services/embargo.py +0 -0
  48. {pangea_sdk-6.6.0 → pangea_sdk-6.8.0}/pangea/services/file_scan.py +0 -0
  49. {pangea_sdk-6.6.0 → pangea_sdk-6.8.0}/pangea/services/intel.py +0 -0
  50. {pangea_sdk-6.6.0 → pangea_sdk-6.8.0}/pangea/services/redact.py +0 -0
  51. {pangea_sdk-6.6.0 → pangea_sdk-6.8.0}/pangea/services/sanitize.py +0 -0
  52. {pangea_sdk-6.6.0 → pangea_sdk-6.8.0}/pangea/services/share/file_format.py +0 -0
  53. {pangea_sdk-6.6.0 → pangea_sdk-6.8.0}/pangea/services/share/share.py +0 -0
  54. {pangea_sdk-6.6.0 → pangea_sdk-6.8.0}/pangea/services/vault/models/asymmetric.py +0 -0
  55. {pangea_sdk-6.6.0 → pangea_sdk-6.8.0}/pangea/services/vault/models/common.py +0 -0
  56. {pangea_sdk-6.6.0 → pangea_sdk-6.8.0}/pangea/services/vault/models/keys.py +0 -0
  57. {pangea_sdk-6.6.0 → pangea_sdk-6.8.0}/pangea/services/vault/models/secret.py +0 -0
  58. {pangea_sdk-6.6.0 → pangea_sdk-6.8.0}/pangea/services/vault/models/symmetric.py +0 -0
  59. {pangea_sdk-6.6.0 → pangea_sdk-6.8.0}/pangea/services/vault/vault.py +0 -0
  60. {pangea_sdk-6.6.0 → pangea_sdk-6.8.0}/pangea/tools.py +0 -0
  61. {pangea_sdk-6.6.0 → pangea_sdk-6.8.0}/pangea/utils.py +0 -0
  62. {pangea_sdk-6.6.0 → pangea_sdk-6.8.0}/pangea/verify_audit.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: pangea-sdk
3
- Version: 6.6.0
3
+ Version: 6.8.0
4
4
  Summary: Pangea API SDK
5
5
  Keywords: Pangea,SDK,Audit
6
6
  Author: Glenn Gallien
@@ -8,16 +8,16 @@ Author-email: Glenn Gallien <glenn.gallien@pangea.cloud>
8
8
  License-Expression: MIT
9
9
  Classifier: Topic :: Software Development
10
10
  Classifier: Topic :: Software Development :: Libraries
11
- Requires-Dist: aiohttp>=3.12.15,<4.0.0
12
- Requires-Dist: cryptography>=45.0.6,<46.0.0
11
+ Requires-Dist: aiohttp>=3.13.0,<4.0.0
12
+ Requires-Dist: cryptography>=46.0.2,<47.0.0
13
13
  Requires-Dist: deprecated>=1.2.18,<2.0.0
14
14
  Requires-Dist: google-crc32c>=1.7.1,<2.0.0
15
- Requires-Dist: pydantic>=2.11.7,<3.0.0
15
+ Requires-Dist: pydantic>=2.12.0,<3.0.0
16
16
  Requires-Dist: python-dateutil>=2.9.0.post0,<3.0.0
17
17
  Requires-Dist: requests>=2.32.5,<3.0.0
18
18
  Requires-Dist: requests-toolbelt>=1.0.0,<2.0.0
19
19
  Requires-Dist: typing-extensions>=4.15.0,<5.0.0
20
- Requires-Dist: yarl>=1.20.1,<2.0.0
20
+ Requires-Dist: yarl>=1.22.0,<2.0.0
21
21
  Requires-Python: >=3.9.2, <4.0.0
22
22
  Project-URL: repository, https://github.com/pangeacyber/pangea-python
23
23
  Description-Content-Type: text/markdown
@@ -1,4 +1,4 @@
1
- __version__ = "6.6.0"
1
+ __version__ = "6.8.0"
2
2
 
3
3
  from pangea.config import PangeaConfig
4
4
  from pangea.file_uploader import FileUploader
@@ -1,12 +1,16 @@
1
1
  from __future__ import annotations
2
2
 
3
- from collections.abc import Sequence
3
+ from collections.abc import Mapping, Sequence
4
4
  from typing import overload
5
5
 
6
+ from typing_extensions import Any, Literal
7
+
6
8
  from pangea.asyncio.services.base import ServiceBaseAsync
7
9
  from pangea.config import PangeaConfig
8
10
  from pangea.response import PangeaResponse
9
11
  from pangea.services.ai_guard import (
12
+ ExtraInfo,
13
+ GuardResult,
10
14
  LogFields,
11
15
  McpToolsMessage,
12
16
  Message,
@@ -194,3 +198,79 @@ class AIGuardAsync(ServiceBaseAsync):
194
198
  ) # type: ignore[assignment]
195
199
 
196
200
  return response
201
+
202
+ async def guard(
203
+ self,
204
+ input: Mapping[str, Any],
205
+ *,
206
+ recipe: str | None = None,
207
+ debug: bool | None = None,
208
+ overrides: Overrides | None = None,
209
+ app_id: str | None = None,
210
+ actor_id: str | None = None,
211
+ llm_provider: str | None = None,
212
+ model: str | None = None,
213
+ model_version: str | None = None,
214
+ request_token_count: int | None = None,
215
+ response_token_count: int | None = None,
216
+ source_ip: str | None = None,
217
+ source_location: str | None = None,
218
+ tenant_id: str | None = None,
219
+ event_type: Literal["input", "output", "tool_input", "tool_output", "tool_listing"] | None = None,
220
+ collector_instance_id: str | None = None,
221
+ extra_info: ExtraInfo | None = None,
222
+ count_tokens: bool | None = None,
223
+ ) -> PangeaResponse[GuardResult]:
224
+ """
225
+ Guard LLM input and output
226
+
227
+ Analyze and redact content to avoid manipulation of the model, addition
228
+ of malicious content, and other undesirable data transfers.
229
+
230
+ OperationId: ai_guard_post_v1_guard
231
+
232
+ Args:
233
+ input: 'messages' (required) contains Prompt content and role array
234
+ in JSON format. The `content` is the multimodal text or image
235
+ input that will be analyzed. Additional properties such as
236
+ 'tools' may be provided for analysis.
237
+ recipe: Recipe key of a configuration of data types and settings defined in the Pangea User Console. It specifies the rules that are to be applied to the text, such as defang malicious URLs.
238
+ debug: Setting this value to true will provide a detailed analysis of the text data
239
+ app_name: Name of source application.
240
+ llm_provider: Underlying LLM. Example: 'OpenAI'.
241
+ model: Model used to perform the event. Example: 'gpt'.
242
+ model_version: Model version used to perform the event. Example: '3.5'.
243
+ request_token_count: Number of tokens in the request.
244
+ response_token_count: Number of tokens in the response.
245
+ source_ip: IP address of user or app or agent.
246
+ source_location: Location of user or app or agent.
247
+ tenant_id: For gateway-like integrations with multi-tenant support.
248
+ event_type: (AIDR) Event Type.
249
+ collector_instance_id: (AIDR) collector instance id.
250
+ extra_info: (AIDR) Logging schema.
251
+ count_tokens: Provide input and output token count.
252
+ """
253
+ return await self.request.post(
254
+ "v1/guard",
255
+ GuardResult,
256
+ data={
257
+ "input": input,
258
+ "recipe": recipe,
259
+ "debug": debug,
260
+ "overrides": overrides,
261
+ "app_id": app_id,
262
+ "actor_id": actor_id,
263
+ "llm_provider": llm_provider,
264
+ "model": model,
265
+ "model_version": model_version,
266
+ "request_token_count": request_token_count,
267
+ "response_token_count": response_token_count,
268
+ "source_ip": source_ip,
269
+ "source_location": source_location,
270
+ "tenant_id": tenant_id,
271
+ "event_type": event_type,
272
+ "collector_instance_id": collector_instance_id,
273
+ "extra_info": extra_info,
274
+ "count_tokens": count_tokens,
275
+ },
276
+ )
@@ -2,6 +2,7 @@ from __future__ import annotations
2
2
 
3
3
  from typing import TYPE_CHECKING
4
4
 
5
+ from pangea._typing import SequenceNotStr
5
6
  from pangea.asyncio.services.base import ServiceBaseAsync
6
7
  from pangea.config import PangeaConfig
7
8
  from pangea.services.prompt_guard import GuardResult, Message
@@ -58,7 +59,7 @@ class PromptGuardAsync(ServiceBaseAsync):
58
59
  self,
59
60
  messages: Iterable[Message],
60
61
  *,
61
- analyzers: Iterable[str] | None = None,
62
+ analyzers: SequenceNotStr[str] | None = None,
62
63
  classify: bool | None = None,
63
64
  ) -> PangeaResponse[GuardResult]:
64
65
  """
@@ -1,7 +1,9 @@
1
1
  from __future__ import annotations
2
2
 
3
- from collections.abc import Sequence
4
- from typing import Any, Generic, Literal, Optional, overload
3
+ from collections.abc import Mapping, Sequence
4
+ from typing import Annotated, Any, Generic, Literal, Optional, overload
5
+
6
+ from pydantic import BaseModel, ConfigDict, Field, RootModel
5
7
 
6
8
  from pangea._typing import T
7
9
  from pangea.config import PangeaConfig
@@ -148,6 +150,13 @@ class SecretsDetectionOverride(APIRequestModel):
148
150
  pangea_token: Optional[PiiEntityAction] = None
149
151
 
150
152
 
153
+ class ImageDetectionItems(APIRequestModel):
154
+ disabled: Optional[bool] = None
155
+ action: Optional[Literal["", "report", "block"]] = ""
156
+ topics: Optional[list[str]] = None
157
+ threshold: Annotated[Optional[float], Field(ge=0.0, le=1.0, multiple_of=0.01)] = None
158
+
159
+
151
160
  class Overrides(APIRequestModel):
152
161
  """Overrides flags."""
153
162
 
@@ -157,6 +166,7 @@ class Overrides(APIRequestModel):
157
166
  code_detection: Optional[CodeDetectionOverride] = None
158
167
  competitors: Optional[CompetitorsOverride] = None
159
168
  gibberish: Optional[GibberishOverride] = None
169
+ image: Optional[ImageDetectionItems] = None
160
170
  language_detection: Optional[LanguageDetectionOverride] = None
161
171
  malicious_entity: Optional[MaliciousEntityOverride] = None
162
172
  pii_entity: Optional[PiiEntityOverride] = None
@@ -280,26 +290,26 @@ class CodeDetectionResult(APIResponseModel):
280
290
  """The action taken by this Detector"""
281
291
 
282
292
 
283
- class TextGuardDetector(APIResponseModel, Generic[T]):
293
+ class GuardDetector(APIResponseModel, Generic[T]):
284
294
  detected: Optional[bool] = None
285
295
  data: Optional[T] = None
286
296
 
287
297
 
288
298
  class TextGuardDetectors(APIResponseModel):
289
- code_detection: Optional[TextGuardDetector[CodeDetectionResult]] = None
290
- competitors: Optional[TextGuardDetector[object]] = None
291
- custom_entity: Optional[TextGuardDetector[object]] = None
292
- gibberish: Optional[TextGuardDetector[object]] = None
293
- hardening: Optional[TextGuardDetector[object]] = None
294
- language_detection: Optional[TextGuardDetector[LanguageDetectionResult]] = None
295
- malicious_entity: Optional[TextGuardDetector[MaliciousEntityResult]] = None
296
- pii_entity: Optional[TextGuardDetector[PiiEntityResult]] = None
297
- profanity_and_toxicity: Optional[TextGuardDetector[object]] = None
298
- prompt_injection: Optional[TextGuardDetector[PromptInjectionResult]] = None
299
- secrets_detection: Optional[TextGuardDetector[SecretsEntityResult]] = None
300
- selfharm: Optional[TextGuardDetector[object]] = None
301
- sentiment: Optional[TextGuardDetector[object]] = None
302
- topic: Optional[TextGuardDetector[TopicDetectionResult]] = None
299
+ code_detection: Optional[GuardDetector[CodeDetectionResult]] = None
300
+ competitors: Optional[GuardDetector[object]] = None
301
+ custom_entity: Optional[GuardDetector[object]] = None
302
+ gibberish: Optional[GuardDetector[object]] = None
303
+ hardening: Optional[GuardDetector[object]] = None
304
+ language_detection: Optional[GuardDetector[LanguageDetectionResult]] = None
305
+ malicious_entity: Optional[GuardDetector[MaliciousEntityResult]] = None
306
+ pii_entity: Optional[GuardDetector[PiiEntityResult]] = None
307
+ profanity_and_toxicity: Optional[GuardDetector[object]] = None
308
+ prompt_injection: Optional[GuardDetector[PromptInjectionResult]] = None
309
+ secrets_detection: Optional[GuardDetector[SecretsEntityResult]] = None
310
+ selfharm: Optional[GuardDetector[object]] = None
311
+ sentiment: Optional[GuardDetector[object]] = None
312
+ topic: Optional[GuardDetector[TopicDetectionResult]] = None
303
313
 
304
314
 
305
315
  class PromptMessage(APIResponseModel):
@@ -336,6 +346,121 @@ class TextGuardResult(PangeaResponseResult):
336
346
  """Whether or not the original input was transformed."""
337
347
 
338
348
 
349
+ class Tool(RootModel[str]):
350
+ root: Annotated[str, Field(min_length=1)]
351
+ """Tool name"""
352
+
353
+
354
+ class McpTool(APIRequestModel):
355
+ server_name: Annotated[str, Field(min_length=1)]
356
+ """MCP server name"""
357
+
358
+ tools: Annotated[list[Tool], Field(min_length=1)]
359
+
360
+
361
+ class ExtraInfo(BaseModel):
362
+ """(AIDR) Logging schema."""
363
+
364
+ # Additional properties are allowed here.
365
+ model_config = ConfigDict(extra="allow")
366
+
367
+ app_name: Optional[str] = None
368
+ """Name of source application/agent."""
369
+
370
+ app_group: Optional[str] = None
371
+ """The group of source application/agent."""
372
+
373
+ app_version: Optional[str] = None
374
+ """Version of the source application/agent."""
375
+
376
+ actor_name: Optional[str] = None
377
+ """Name of subject actor/service account."""
378
+
379
+ actor_group: Optional[str] = None
380
+ """The group of subject actor."""
381
+
382
+ source_region: Optional[str] = None
383
+ """Geographic region or data center."""
384
+
385
+ sub_tenant: Optional[str] = None
386
+ """Sub tenant of the user or organization"""
387
+ mcp_tools: Optional[Sequence[McpTool]] = None
388
+
389
+ """Each item groups tools for a given MCP server."""
390
+
391
+
392
+ class AccessRuleResult(APIResponseModel):
393
+ """
394
+ Details about the evaluation of a single rule, including whether it matched,
395
+ the action to take, the rule name, and optional debugging information.
396
+ """
397
+
398
+ matched: bool
399
+ """Whether this rule's logic evaluated to true for the input."""
400
+
401
+ action: str
402
+ """
403
+ The action resulting from the rule evaluation. One of 'allowed', 'blocked',
404
+ or 'reported'.
405
+ """
406
+
407
+ name: str
408
+ """A human-readable name for the rule."""
409
+
410
+ logic: Optional[dict[str, Any]] = None
411
+ """The JSON logic expression evaluated for this rule."""
412
+
413
+ attributes: Optional[dict[str, Any]] = None
414
+ """The input attribute values that were available during rule evaluation."""
415
+
416
+
417
+ class GuardDetectors(APIResponseModel):
418
+ """Result of the recipe analyzing and input prompt."""
419
+
420
+ code: Optional[GuardDetector[CodeDetectionResult]] = None
421
+ competitors: Optional[GuardDetector[object]] = None
422
+ confidential_and_pii_entity: Optional[GuardDetector[PiiEntityResult]] = None
423
+ custom_entity: Optional[GuardDetector[object]] = None
424
+ language: Optional[GuardDetector[LanguageDetectionResult]] = None
425
+ malicious_entity: Optional[GuardDetector[MaliciousEntityResult]] = None
426
+ malicious_prompt: Optional[GuardDetector[PromptInjectionResult]] = None
427
+ prompt_hardening: Optional[GuardDetector[object]] = None
428
+ secret_and_key_entity: Optional[GuardDetector[SecretsEntityResult]] = None
429
+ topic: Optional[GuardDetector[TopicDetectionResult]] = None
430
+
431
+
432
+ class GuardResult(PangeaResponseResult):
433
+ output: Optional[dict[str, Any]] = None
434
+ """Updated structured prompt."""
435
+
436
+ blocked: Optional[bool] = None
437
+ """Whether or not the prompt triggered a block detection."""
438
+
439
+ transformed: Optional[bool] = None
440
+ """Whether or not the original input was transformed."""
441
+
442
+ recipe: Optional[str] = None
443
+ """The Recipe that was used."""
444
+
445
+ detectors: GuardDetectors
446
+ """Result of the recipe analyzing and input prompt."""
447
+
448
+ access_rules: Optional[dict[str, AccessRuleResult]] = None
449
+ """Result of the recipe evaluating configured rules"""
450
+
451
+ fpe_context: Optional[str] = None
452
+ """
453
+ If an FPE redaction method returned results, this will be the context passed
454
+ to unredact.
455
+ """
456
+
457
+ input_token_count: Optional[float] = None
458
+ """Number of tokens counted in the input"""
459
+
460
+ output_token_count: Optional[float] = None
461
+ """Number of tokens counted in the output"""
462
+
463
+
339
464
  class AIGuard(ServiceBase):
340
465
  """AI Guard service client.
341
466
 
@@ -514,6 +639,82 @@ class AIGuard(ServiceBase):
514
639
 
515
640
  return response
516
641
 
642
+ def guard(
643
+ self,
644
+ input: Mapping[str, Any],
645
+ *,
646
+ recipe: str | None = None,
647
+ debug: bool | None = None,
648
+ overrides: Overrides | None = None,
649
+ app_id: str | None = None,
650
+ actor_id: str | None = None,
651
+ llm_provider: str | None = None,
652
+ model: str | None = None,
653
+ model_version: str | None = None,
654
+ request_token_count: int | None = None,
655
+ response_token_count: int | None = None,
656
+ source_ip: str | None = None,
657
+ source_location: str | None = None,
658
+ tenant_id: str | None = None,
659
+ event_type: Literal["input", "output", "tool_input", "tool_output", "tool_listing"] | None = None,
660
+ collector_instance_id: str | None = None,
661
+ extra_info: ExtraInfo | None = None,
662
+ count_tokens: bool | None = None,
663
+ ) -> PangeaResponse[GuardResult]:
664
+ """
665
+ Guard LLM input and output
666
+
667
+ Analyze and redact content to avoid manipulation of the model, addition
668
+ of malicious content, and other undesirable data transfers.
669
+
670
+ OperationId: ai_guard_post_v1_guard
671
+
672
+ Args:
673
+ input: 'messages' (required) contains Prompt content and role array
674
+ in JSON format. The `content` is the multimodal text or image
675
+ input that will be analyzed. Additional properties such as
676
+ 'tools' may be provided for analysis.
677
+ recipe: Recipe key of a configuration of data types and settings defined in the Pangea User Console. It specifies the rules that are to be applied to the text, such as defang malicious URLs.
678
+ debug: Setting this value to true will provide a detailed analysis of the text data
679
+ app_name: Name of source application.
680
+ llm_provider: Underlying LLM. Example: 'OpenAI'.
681
+ model: Model used to perform the event. Example: 'gpt'.
682
+ model_version: Model version used to perform the event. Example: '3.5'.
683
+ request_token_count: Number of tokens in the request.
684
+ response_token_count: Number of tokens in the response.
685
+ source_ip: IP address of user or app or agent.
686
+ source_location: Location of user or app or agent.
687
+ tenant_id: For gateway-like integrations with multi-tenant support.
688
+ event_type: (AIDR) Event Type.
689
+ collector_instance_id: (AIDR) collector instance id.
690
+ extra_info: (AIDR) Logging schema.
691
+ count_tokens: Provide input and output token count.
692
+ """
693
+ return self.request.post(
694
+ "v1/guard",
695
+ GuardResult,
696
+ data={
697
+ "input": input,
698
+ "recipe": recipe,
699
+ "debug": debug,
700
+ "overrides": overrides,
701
+ "app_id": app_id,
702
+ "actor_id": actor_id,
703
+ "llm_provider": llm_provider,
704
+ "model": model,
705
+ "model_version": model_version,
706
+ "request_token_count": request_token_count,
707
+ "response_token_count": response_token_count,
708
+ "source_ip": source_ip,
709
+ "source_location": source_location,
710
+ "tenant_id": tenant_id,
711
+ "event_type": event_type,
712
+ "collector_instance_id": collector_instance_id,
713
+ "extra_info": extra_info,
714
+ "count_tokens": count_tokens,
715
+ },
716
+ )
717
+
517
718
 
518
719
  def get_relevant_content(
519
720
  messages: Sequence[Message | McpToolsMessage],
@@ -1,7 +1,10 @@
1
1
  from __future__ import annotations
2
2
 
3
- from typing import TYPE_CHECKING, Literal, Optional
3
+ from typing import TYPE_CHECKING, Annotated, Literal, Optional
4
4
 
5
+ from pydantic import Field
6
+
7
+ from pangea._typing import SequenceNotStr
5
8
  from pangea.config import PangeaConfig
6
9
  from pangea.response import APIRequestModel, APIResponseModel, PangeaResponse, PangeaResponseResult
7
10
  from pangea.services.base import ServiceBase
@@ -33,19 +36,18 @@ class GuardResult(PangeaResponseResult):
33
36
  detected: bool
34
37
  """Boolean response for if the prompt was considered malicious or not"""
35
38
 
39
+ analyzer: Optional[str] = None
40
+
36
41
  type: Optional[Literal["direct", "indirect", ""]] = None
37
42
  """Type of analysis, either direct or indirect"""
38
43
 
39
- analyzer: Optional[str] = None
40
- """Prompt Analyzers for identifying and rejecting properties of prompts"""
41
-
42
- confidence: float
44
+ confidence: Annotated[Optional[float], Field(ge=0.0, le=1.0)] = None
43
45
  """Percent of confidence in the detection result, ranging from 0 to 1"""
44
46
 
45
47
  info: Optional[str] = None
46
48
  """Extra information about the detection result"""
47
49
 
48
- classifications: list[Classification]
50
+ classifications: Optional[list[Classification]] = None
49
51
  """List of classification results with labels and confidence scores"""
50
52
 
51
53
 
@@ -92,7 +94,7 @@ class PromptGuard(ServiceBase):
92
94
  self,
93
95
  messages: Iterable[Message],
94
96
  *,
95
- analyzers: Iterable[str] | None = None,
97
+ analyzers: SequenceNotStr[str] | None = None,
96
98
  classify: bool | None = None,
97
99
  ) -> PangeaResponse[GuardResult]:
98
100
  """
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "pangea-sdk"
3
- version = "6.6.0"
3
+ version = "6.8.0"
4
4
  description = "Pangea API SDK"
5
5
  authors = [
6
6
  {name = "Glenn Gallien", email = "glenn.gallien@pangea.cloud"}
@@ -14,16 +14,16 @@ classifiers = [
14
14
  ]
15
15
  requires-python = ">=3.9.2,<4.0.0"
16
16
  dependencies = [
17
- "aiohttp (>=3.12.15,<4.0.0)",
18
- "cryptography (>=45.0.6,<46.0.0)",
17
+ "aiohttp (>=3.13.0,<4.0.0)",
18
+ "cryptography (>=46.0.2,<47.0.0)",
19
19
  "deprecated (>=1.2.18,<2.0.0)",
20
20
  "google-crc32c (>=1.7.1,<2.0.0)",
21
- "pydantic (>=2.11.7,<3.0.0)",
21
+ "pydantic (>=2.12.0,<3.0.0)",
22
22
  "python-dateutil (>=2.9.0.post0,<3.0.0)",
23
23
  "requests (>=2.32.5,<3.0.0)",
24
24
  "requests-toolbelt (>=1.0.0,<2.0.0)",
25
25
  "typing-extensions (>=4.15.0,<5.0.0)",
26
- "yarl (>=1.20.1,<2.0.0)"
26
+ "yarl (>=1.22.0,<2.0.0)"
27
27
  ]
28
28
 
29
29
  [project.urls]
@@ -32,15 +32,15 @@ repository = "https://github.com/pangeacyber/pangea-python"
32
32
  [dependency-groups]
33
33
  dev = [
34
34
  "docstring-parser ==0.17.0",
35
- "pytest-asyncio ==1.1.0",
35
+ "pytest-asyncio ==1.2.0",
36
36
  "pytest_httpserver ==1.1.3",
37
37
  "types-Deprecated ==1.2.15.20250304",
38
- "types-python-dateutil ==2.9.0.20250822",
39
- "types-requests ==2.32.4.20250809",
38
+ "types-python-dateutil ==2.9.0.20251008",
39
+ "types-requests ==2.32.4.20250913",
40
40
  ]
41
41
 
42
42
  [build-system]
43
- requires = ["uv_build==0.8.14"]
43
+ requires = ["uv_build==0.9.2"]
44
44
  build-backend = "uv_build"
45
45
 
46
46
  [tool.mypy]
@@ -54,7 +54,7 @@ warn_unused_ignores = true
54
54
  plugins = ['pydantic.mypy']
55
55
 
56
56
  [tool.pydantic-mypy]
57
- init_forbid_extra = true
57
+ init_forbid_extra = false
58
58
  init_typed = true
59
59
  warn_required_dynamic_aliases = true
60
60
 
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes