swiftapi-python 1.2.0__py3-none-any.whl → 1.2.2__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.
swiftapi/__init__.py CHANGED
@@ -29,7 +29,7 @@ Usage:
29
29
  db.update(user_id, data)
30
30
  """
31
31
 
32
- __version__ = "1.2.0"
32
+ __version__ = "1.2.2"
33
33
  __author__ = "Rayan Pal"
34
34
 
35
35
  # Core exports
swiftapi/anthropic.py CHANGED
@@ -17,6 +17,7 @@ import json
17
17
  import requests
18
18
  from typing import List, Dict, Optional, Any
19
19
 
20
+ from . import __version__
20
21
  from .exceptions import SwiftAPIError, AuthenticationError, NetworkError
21
22
 
22
23
 
@@ -113,7 +114,7 @@ class Messages:
113
114
  headers={
114
115
  "X-SwiftAPI-Authority": self._swiftapi_key,
115
116
  "Content-Type": "application/json",
116
- "User-Agent": "swiftapi-python/1.2.0",
117
+ "User-Agent": f"swiftapi-python/{__version__}",
117
118
  },
118
119
  timeout=self._timeout,
119
120
  )
@@ -152,7 +153,7 @@ class Messages:
152
153
  "x-api-key": self._anthropic_key,
153
154
  "anthropic-version": "2023-06-01",
154
155
  "Content-Type": "application/json",
155
- "User-Agent": "swiftapi-python/1.2.0",
156
+ "User-Agent": f"swiftapi-python/{__version__}",
156
157
  },
157
158
  timeout=self._timeout,
158
159
  )
swiftapi/client.py CHANGED
@@ -7,6 +7,7 @@ This module provides the HTTP client for communicating with SwiftAPI.
7
7
  import requests
8
8
  from typing import Dict, Any, Optional, List
9
9
 
10
+ from . import __version__
10
11
  from .exceptions import (
11
12
  SwiftAPIError,
12
13
  AuthenticationError,
@@ -54,7 +55,7 @@ class SwiftAPI:
54
55
  self._session.headers.update({
55
56
  "X-SwiftAPI-Authority": key,
56
57
  "Content-Type": "application/json",
57
- "User-Agent": "swiftapi-python/1.0.0",
58
+ "User-Agent": f"swiftapi-python/{__version__}",
58
59
  })
59
60
 
60
61
  def _request(
@@ -110,10 +111,12 @@ class SwiftAPI:
110
111
 
111
112
  # Policy violations (denied actions)
112
113
  if response.status_code == 200 and data.get("approved") is False:
114
+ reason = data.get("denial_reason") or data.get("reason", "Action denied by policy")
115
+ action_type = data.get("action_type") or data.get("action", {}).get("type")
113
116
  raise PolicyViolation(
114
- message=data.get("reason", "Action denied by policy"),
115
- action_type=data.get("action", {}).get("type"),
116
- denial_reason=data.get("reason"),
117
+ message=reason,
118
+ action_type=action_type,
119
+ denial_reason=reason,
117
120
  )
118
121
 
119
122
  # Other errors
swiftapi/openai.py CHANGED
@@ -17,6 +17,7 @@ import json
17
17
  import requests
18
18
  from typing import List, Dict, Optional, Any
19
19
 
20
+ from . import __version__
20
21
  from .exceptions import SwiftAPIError, AuthenticationError, NetworkError
21
22
 
22
23
 
@@ -117,7 +118,7 @@ class Completions:
117
118
  headers={
118
119
  "X-SwiftAPI-Authority": self._swiftapi_key,
119
120
  "Content-Type": "application/json",
120
- "User-Agent": "swiftapi-python/1.1.1",
121
+ "User-Agent": f"swiftapi-python/{__version__}",
121
122
  },
122
123
  timeout=self._timeout,
123
124
  )
@@ -152,7 +153,7 @@ class Completions:
152
153
  headers={
153
154
  "Authorization": f"Bearer {self._openai_key}",
154
155
  "Content-Type": "application/json",
155
- "User-Agent": "swiftapi-python/1.1.1",
156
+ "User-Agent": f"swiftapi-python/{__version__}",
156
157
  },
157
158
  timeout=self._timeout,
158
159
  )
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: swiftapi-python
3
- Version: 1.2.0
3
+ Version: 1.2.2
4
4
  Summary: SwiftAPI Python SDK - AI Action Verification Gateway
5
5
  Author-email: Rayan Pal <rayan@swiftapi.ai>
6
6
  License-Expression: MIT
@@ -19,6 +19,7 @@ Classifier: Topic :: Security
19
19
  Classifier: Topic :: Software Development :: Libraries :: Python Modules
20
20
  Requires-Python: >=3.9
21
21
  Description-Content-Type: text/markdown
22
+ License-File: LICENSE
22
23
  Requires-Dist: requests>=2.31.0
23
24
  Requires-Dist: pynacl>=1.5.0
24
25
  Requires-Dist: colorama>=0.4.6
@@ -28,6 +29,7 @@ Requires-Dist: pytest-cov>=4.0.0; extra == "dev"
28
29
  Requires-Dist: black>=23.0.0; extra == "dev"
29
30
  Requires-Dist: mypy>=1.0.0; extra == "dev"
30
31
  Requires-Dist: types-requests>=2.31.0; extra == "dev"
32
+ Dynamic: license-file
31
33
 
32
34
  # SwiftAPI Python SDK
33
35
 
@@ -0,0 +1,13 @@
1
+ swiftapi/__init__.py,sha256=lCk2KIRL72P7AYwFy0KwJV6AWt_E8npD3oyX85oyfYA,2061
2
+ swiftapi/anthropic.py,sha256=aTgCNWHigmJf0zUz9OpmUS3Ej_2bA_EY70lnMTlhBiI,7680
3
+ swiftapi/client.py,sha256=DIB66PMh6I48PMwmqqy08kzQrxa0dSg7lw9vK_GJsMg,10309
4
+ swiftapi/enforcement.py,sha256=L-2JKvvL5U3Q4ZU_o889RxZteuN-ELuxKGIMUXtx2sw,8725
5
+ swiftapi/exceptions.py,sha256=hBleOCc1WwDEM70WNYTy1TDOSOaBJSx3PtzFzfmVOGY,1701
6
+ swiftapi/openai.py,sha256=9erzv6J4Ts2PuqhV030QyIm5yE0UxomA0y2qW9-slKQ,7670
7
+ swiftapi/utils.py,sha256=Sn6ED6ltECCYc-ce9fhxZxgzBthvflPCZelXPPzskZM,3145
8
+ swiftapi/verifier.py,sha256=SpeTo3tHTVxz7-R8o5_kLIhEJV6aDOUG0ud4WcSWDBg,4768
9
+ swiftapi_python-1.2.2.dist-info/licenses/LICENSE,sha256=btq3h42ZP3swvtQ3ak5k3sP_Y6yRwzL5zrV7EzNeRus,1087
10
+ swiftapi_python-1.2.2.dist-info/METADATA,sha256=iJTgLr1jb0MZQuXhoSjmjpYPdvyyXSzHVEZAiWKb3VA,7674
11
+ swiftapi_python-1.2.2.dist-info/WHEEL,sha256=YCfwYGOYMi5Jhw2fU4yNgwErybb2IX5PEwBKV4ZbdBo,91
12
+ swiftapi_python-1.2.2.dist-info/top_level.txt,sha256=oio-d2BTrT91P7dmufUhlSYjOtWBh4bOYz6rsTDDvu4,9
13
+ swiftapi_python-1.2.2.dist-info/RECORD,,
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: setuptools (81.0.0)
2
+ Generator: setuptools (82.0.0)
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
5
5
 
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Rayan Pal
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -1,12 +0,0 @@
1
- swiftapi/__init__.py,sha256=EyScD0SEm42NWp6t1cLQhI22bzi3vpinIA49ZUprgSE,2061
2
- swiftapi/anthropic.py,sha256=B39l2fZmrjNwpjEMgU4Gc9BVVq09F2BoVTh7AP4RDEA,7635
3
- swiftapi/client.py,sha256=LCUg9hNP17wfe9pfumfA3w_hWR2vd8fhAkuZP2HlHDo,10161
4
- swiftapi/enforcement.py,sha256=L-2JKvvL5U3Q4ZU_o889RxZteuN-ELuxKGIMUXtx2sw,8725
5
- swiftapi/exceptions.py,sha256=hBleOCc1WwDEM70WNYTy1TDOSOaBJSx3PtzFzfmVOGY,1701
6
- swiftapi/openai.py,sha256=Crd5teg7FBB_cGSBy_m4Z-khE81Z-4xWhFkfaU1YYT0,7625
7
- swiftapi/utils.py,sha256=Sn6ED6ltECCYc-ce9fhxZxgzBthvflPCZelXPPzskZM,3145
8
- swiftapi/verifier.py,sha256=SpeTo3tHTVxz7-R8o5_kLIhEJV6aDOUG0ud4WcSWDBg,4768
9
- swiftapi_python-1.2.0.dist-info/METADATA,sha256=L8PcNjE8mhWLVZMgxKUy9tjFF0_B59uI32-DpABF01g,7630
10
- swiftapi_python-1.2.0.dist-info/WHEEL,sha256=YLJXdYXQ2FQ0Uqn2J-6iEIC-3iOey8lH3xCtvFLkd8Q,91
11
- swiftapi_python-1.2.0.dist-info/top_level.txt,sha256=oio-d2BTrT91P7dmufUhlSYjOtWBh4bOYz6rsTDDvu4,9
12
- swiftapi_python-1.2.0.dist-info/RECORD,,