orbitals 0.1.1__py3-none-any.whl → 0.1.3__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.
@@ -38,7 +38,9 @@ def serve(
38
38
  "0.0.0.0", "-h", "--host", help="The host to use for the server"
39
39
  ),
40
40
  vllm_port: int = typer.Option(8001, help="The port to use for the vLLM server"),
41
- vllm_max_model_len: int = typer.Option(10000, help="Maximum model length for vLLM"),
41
+ vllm_max_model_len: int = typer.Option(
42
+ 30_000, help="Maximum model length for vLLM"
43
+ ),
42
44
  vllm_max_num_seqs: int = typer.Option(
43
45
  2, help="Maximum number of sequences for vLLM"
44
46
  ),
@@ -106,7 +106,7 @@ class APIScopeGuard(ScopeGuard):
106
106
  skip_evidences: bool | None = None,
107
107
  ) -> ScopeGuardOutput:
108
108
  response = requests.post(
109
- f"{self.api_url}/api/orbitals/scope-guard/validate",
109
+ f"{self.api_url}/orbitals/scope-guard/validate",
110
110
  json=_build_request_data(
111
111
  conversation,
112
112
  skip_evidences if skip_evidences is not None else self.skip_evidences,
@@ -134,7 +134,7 @@ class APIScopeGuard(ScopeGuard):
134
134
  skip_evidences: bool | None = None,
135
135
  ) -> list[ScopeGuardOutput]:
136
136
  response = requests.post(
137
- f"{self.api_url}/api/orbitals/scope-guard/batch-validate",
137
+ f"{self.api_url}/orbitals/scope-guard/batch-validate",
138
138
  json=_build_batch_request_data(
139
139
  conversations,
140
140
  skip_evidences if skip_evidences is not None else self.skip_evidences,
@@ -185,7 +185,7 @@ class AsyncAPIScopeGuard(AsyncScopeGuard):
185
185
  ) -> ScopeGuardOutput:
186
186
  async with aiohttp.ClientSession() as session:
187
187
  response = await session.post(
188
- f"{self.api_url}/api/in/scope-guard/validate",
188
+ f"{self.api_url}/in/scope-guard/validate",
189
189
  json=_build_request_data(
190
190
  conversation,
191
191
  skip_evidences
@@ -216,7 +216,7 @@ class AsyncAPIScopeGuard(AsyncScopeGuard):
216
216
  ) -> list[ScopeGuardOutput]:
217
217
  async with aiohttp.ClientSession() as session:
218
218
  response = await session.post(
219
- f"{self.api_url}/api/in/scope-guard/batch-validate",
219
+ f"{self.api_url}/in/scope-guard/batch-validate",
220
220
  json=_build_batch_request_data(
221
221
  conversations,
222
222
  skip_evidences
@@ -139,7 +139,7 @@ class ScopeGuard(BaseScopeGuard):
139
139
  backend: Literal["hf"] = "hf",
140
140
  model: DefaultModel | str = "scope-guard",
141
141
  skip_evidences: bool = False,
142
- max_new_tokens: int = 10_000,
142
+ max_new_tokens: int = 3000,
143
143
  do_sample: bool = False,
144
144
  **kwargs,
145
145
  ) -> HuggingFaceScopeGuard: ...
@@ -151,8 +151,8 @@ class ScopeGuard(BaseScopeGuard):
151
151
  model: DefaultModel | str = "scope-guard",
152
152
  skip_evidences: bool = False,
153
153
  temperature: float = 0.0,
154
- max_tokens: int = 10_000,
155
- max_model_len: int = 10_000,
154
+ max_tokens: int = 3000,
155
+ max_model_len: int = 30_000,
156
156
  max_num_seqs: int = 2,
157
157
  ) -> VLLMScopeGuard: ...
158
158
 
@@ -227,7 +227,7 @@ class AsyncScopeGuard(BaseScopeGuard):
227
227
  skip_evidences: bool = False,
228
228
  vllm_serving_url: str = "http://localhost:8000",
229
229
  temperature: float = 0.0,
230
- max_tokens: int = 10_000,
230
+ max_tokens: int = 3000,
231
231
  ) -> AsyncVLLMApiScopeGuard: ...
232
232
 
233
233
  @overload
@@ -23,7 +23,7 @@ class HuggingFaceScopeGuard(ScopeGuard):
23
23
  backend: Literal["hf"] = "hf",
24
24
  model: DefaultModel | str = "scope-guard",
25
25
  skip_evidences: bool = False,
26
- max_new_tokens: int = 10_000,
26
+ max_new_tokens: int = 3000,
27
27
  do_sample: bool = False,
28
28
  **kwargs,
29
29
  ):
@@ -26,8 +26,8 @@ class VLLMScopeGuard(ScopeGuard):
26
26
  model: DefaultModel | str = "scope-guard",
27
27
  skip_evidences: bool = False,
28
28
  temperature: float = 0.0,
29
- max_tokens: int = 10_000,
30
- max_model_len: int = 10_000,
29
+ max_tokens: int = 3000,
30
+ max_model_len: int = 30_000,
31
31
  max_num_seqs: int = 2,
32
32
  gpu_memory_utilization: float = 0.9,
33
33
  ):
@@ -131,7 +131,7 @@ class AsyncVLLMApiScopeGuard(AsyncScopeGuard):
131
131
  skip_evidences: bool = False,
132
132
  vllm_serving_url: str = "http://localhost:8000",
133
133
  temperature: float = 0.0,
134
- max_tokens: int = 10_000,
134
+ max_tokens: int = 3000,
135
135
  ):
136
136
  import transformers
137
137
 
@@ -1,7 +1,7 @@
1
1
  from enum import Enum
2
- from typing import Literal
2
+ from typing import Annotated, Any, Literal
3
3
 
4
- from pydantic import BaseModel, TypeAdapter
4
+ from pydantic import BaseModel, BeforeValidator, TypeAdapter
5
5
 
6
6
  from ..types import ConversationMessage, LLMUsage
7
7
 
@@ -66,6 +66,23 @@ class ConversationUserMessage(BaseModel):
66
66
  content: str
67
67
 
68
68
 
69
- ScopeGuardInput = str | ConversationUserMessage | list[ConversationMessage]
69
+ def _select_model_based_on_fields(
70
+ v: Any,
71
+ ) -> str | ConversationUserMessage | list[ConversationMessage]:
72
+ if isinstance(v, str):
73
+ return TypeAdapter(str).validate_python(v)
74
+ elif isinstance(v, dict):
75
+ return TypeAdapter(ConversationUserMessage).validate_python(v)
76
+ elif isinstance(v, list):
77
+ return TypeAdapter(list[ConversationMessage]).validate_python(v)
78
+
79
+ # no matching model found, let's fall back to standard pydantic behavior
80
+ return v
81
+
82
+
83
+ ScopeGuardInput = Annotated[
84
+ str | ConversationUserMessage | list[ConversationMessage],
85
+ BeforeValidator(_select_model_based_on_fields),
86
+ ]
70
87
 
71
88
  ScopeGuardInputTypeAdapter = TypeAdapter(ScopeGuardInput)
orbitals/utils.py CHANGED
@@ -17,7 +17,7 @@ def maybe_configure_gpu_usage():
17
17
  return
18
18
 
19
19
  try:
20
- import pynvml # ty: ignore[unresolved-import] # provided by nvidia-ml-py
20
+ import pynvml # ty: ignore[unresolved-import]
21
21
  except ModuleNotFoundError:
22
22
  logging.debug("nvidia-ml-py not available, skipping GPU auto-configuration")
23
23
  return
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: orbitals
3
- Version: 0.1.1
3
+ Version: 0.1.3
4
4
  Summary: LLM Guardrails tailored to your Principles
5
5
  Author-email: Luigi Procopio <luigi@principled-intelligence.com>, Edoardo Barba <edoardo@principled-intelligence.com>
6
6
  License: Apache-2.0
@@ -11,7 +11,7 @@ Classifier: Programming Language :: Python :: 3.11
11
11
  Classifier: Programming Language :: Python :: 3.12
12
12
  Classifier: Programming Language :: Python :: 3.13
13
13
  Classifier: Programming Language :: Python :: 3.14
14
- Requires-Python: ==3.13
14
+ Requires-Python: >=3.10
15
15
  Requires-Dist: aiohttp
16
16
  Requires-Dist: pydantic>=2.0.0
17
17
  Requires-Dist: requests
@@ -22,7 +22,7 @@ Requires-Dist: fastapi[standard]>=0.119.1; extra == 'all'
22
22
  Requires-Dist: nvidia-ml-py; extra == 'all'
23
23
  Requires-Dist: transformers<5.0.0,>=4.47.0; extra == 'all'
24
24
  Requires-Dist: uvicorn>=0.29.0; extra == 'all'
25
- Requires-Dist: vllm<0.13.0,>=0.11.0; extra == 'all'
25
+ Requires-Dist: vllm>=0.11.0; extra == 'all'
26
26
  Requires-Dist: xgrammar; extra == 'all'
27
27
  Provides-Extra: scope-guard-all
28
28
  Requires-Dist: accelerate>=1.11.0; extra == 'scope-guard-all'
@@ -30,7 +30,7 @@ Requires-Dist: fastapi[standard]>=0.119.1; extra == 'scope-guard-all'
30
30
  Requires-Dist: nvidia-ml-py; extra == 'scope-guard-all'
31
31
  Requires-Dist: transformers<5.0.0,>=4.47.0; extra == 'scope-guard-all'
32
32
  Requires-Dist: uvicorn>=0.29.0; extra == 'scope-guard-all'
33
- Requires-Dist: vllm<0.13.0,>=0.11.0; extra == 'scope-guard-all'
33
+ Requires-Dist: vllm>=0.11.0; extra == 'scope-guard-all'
34
34
  Requires-Dist: xgrammar; extra == 'scope-guard-all'
35
35
  Provides-Extra: scope-guard-hf
36
36
  Requires-Dist: accelerate>=1.11.0; extra == 'scope-guard-hf'
@@ -41,12 +41,12 @@ Requires-Dist: fastapi[standard]>=0.119.1; extra == 'scope-guard-serve'
41
41
  Requires-Dist: nvidia-ml-py; extra == 'scope-guard-serve'
42
42
  Requires-Dist: transformers<5.0.0,>=4.47.0; extra == 'scope-guard-serve'
43
43
  Requires-Dist: uvicorn>=0.29.0; extra == 'scope-guard-serve'
44
- Requires-Dist: vllm<0.13.0,>=0.11.0; extra == 'scope-guard-serve'
44
+ Requires-Dist: vllm>=0.11.0; extra == 'scope-guard-serve'
45
45
  Requires-Dist: xgrammar; extra == 'scope-guard-serve'
46
46
  Provides-Extra: scope-guard-vllm
47
47
  Requires-Dist: nvidia-ml-py; extra == 'scope-guard-vllm'
48
48
  Requires-Dist: transformers<5.0.0,>=4.47.0; extra == 'scope-guard-vllm'
49
- Requires-Dist: vllm<0.13.0,>=0.11.0; extra == 'scope-guard-vllm'
49
+ Requires-Dist: vllm>=0.11.0; extra == 'scope-guard-vllm'
50
50
  Requires-Dist: xgrammar; extra == 'scope-guard-vllm'
51
51
  Provides-Extra: serving
52
52
  Requires-Dist: fastapi[standard]>=0.119.1; extra == 'serving'
@@ -54,7 +54,7 @@ Requires-Dist: uvicorn>=0.29.0; extra == 'serving'
54
54
  Description-Content-Type: text/markdown
55
55
 
56
56
  <div align="center">
57
- <img src="assets/orbitals-banner.png" width="70%" />
57
+ <img src="https://raw.githubusercontent.com/Principled-Intelligence/orbitals/refs/heads/main/assets/orbitals-banner.png" width="70%" />
58
58
  <h3 align="center">
59
59
  <p>
60
60
  <b>LLM Guardrails tailored to your Principles</b>
@@ -63,10 +63,16 @@ Description-Content-Type: text/markdown
63
63
  </div>
64
64
 
65
65
  <p align="center">
66
- <img src="https://img.shields.io/pypi/v/orbitals?color=green" alt="PyPI Version">
66
+ <a href="https://pypi.org/project/orbitals/">
67
+ <img src="https://img.shields.io/pypi/v/orbitals?color=green" alt="PyPI Version">
68
+ </a>
67
69
  <!-- <img src="https://img.shields.io/badge/type%20checked-ty-blue.svg?color=green" alt="Type Checked with ty"> -->
68
- <img src="https://img.shields.io/pypi/pyversions/orbitals" alt="Python Versions">
69
- <img src="https://img.shields.io/github/license/principled-intelligence/orbitals" alt="GitHub License">
70
+ <a href="https://pypi.org/project/orbitals/">
71
+ <img src="https://img.shields.io/pypi/pyversions/orbitals" alt="Python Versions">
72
+ </a>
73
+ <a href="https://raw.githubusercontent.com/Principled-Intelligence/orbitals/refs/heads/main/LICENSE">
74
+ <img src="https://img.shields.io/github/license/principled-intelligence/orbitals" alt="GitHub License">
75
+ </a>
70
76
  </p>
71
77
 
72
78
  ## Overview
@@ -1,25 +1,25 @@
1
1
  orbitals/__init__.py,sha256=ED6jHcYiuYpr_0vjGz0zx2lrrmJT9sDJCzIljoDfmlM,65
2
2
  orbitals/types.py,sha256=4oRinWPG6kbtW4lQ8bHrDmxEotncqMIwLCmQ2yGH7PI,1988
3
- orbitals/utils.py,sha256=FoCNGgPNqD4mey7_f3Rj5XBJKsp7-krcvvr5KvmnNG4,1677
3
+ orbitals/utils.py,sha256=yofeiyFJfykrSBpLSK3xF70_yoODrK3m3v54MjZ3Ls4,1649
4
4
  orbitals/cli/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
5
5
  orbitals/cli/main.py,sha256=p4MEbmtJ0L8mLiyovEq7urnVc6I0mbbCNdGEtGyY60Y,197
6
6
  orbitals/scope_guard/__init__.py,sha256=0gzzSXpfRvIcCYpu3AKQSMFYDMDJaknY9pdypt7HiuI,197
7
- orbitals/scope_guard/modeling.py,sha256=hsYSrAHnDBe954OnSDyTBa6FGyxx6MA0L4BS2W-86Yc,2911
7
+ orbitals/scope_guard/modeling.py,sha256=VBB4ayGbSekFjY8jZ3Gaomyb0w1UaHUgZ4gN0A2yxko,3500
8
8
  orbitals/scope_guard/prompting.py,sha256=0oV1YgklMm1bikR4anDJMP1_NFpGzfwNYk--iluWK7Y,4174
9
9
  orbitals/scope_guard/cli/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
10
10
  orbitals/scope_guard/cli/convert_default_model_name.py,sha256=f6iwEigcyoi99uqgntUx36ph7S1lXv72hA0rkrjbMM8,247
11
11
  orbitals/scope_guard/cli/main.py,sha256=jz8fQ2e4VFZQti982feVWGpL9fT7yZeanq14pX5WAkM,219
12
- orbitals/scope_guard/cli/serve.py,sha256=EM6yNSviwot8Im-MG1_AA4PsOkZXW9W2CmokqNfq7es,4611
12
+ orbitals/scope_guard/cli/serve.py,sha256=vcDbNd7FBTfnlmmf7R-hqbUKJIkHwh2K_npCQxwGtc0,4626
13
13
  orbitals/scope_guard/guards/__init__.py,sha256=B1EA9YtaTQ3ko5d2wFK2y4bXKrV8MclAELAievmZjxg,376
14
- orbitals/scope_guard/guards/api.py,sha256=S8VX4_8VIhtg3_IP4Eh50l1uarcJBagGXNEEl1BZjag,8514
15
- orbitals/scope_guard/guards/base.py,sha256=5DQeOY7kvTgH6GSExMpy3b_KQtNWzSlrudro6giQ-Ec,9798
16
- orbitals/scope_guard/guards/hf.py,sha256=xFNl_DtRiePB3n3V2spsSwiRRYz1qZYNw-wQTyiZsCI,3967
17
- orbitals/scope_guard/guards/vllm.py,sha256=3LU9DKKniQd90Ibaq2Wef20fyoZXgkeQtc58XY6kX2I,8983
14
+ orbitals/scope_guard/guards/api.py,sha256=d621Cw8kF5251_Mn5kpXCunzrRXVvVb_6JPP1sUlabg,8498
15
+ orbitals/scope_guard/guards/base.py,sha256=13IqwE3a0BtTVOmRnfBHiTuDLi18H7B_YqThCokJ6OY,9792
16
+ orbitals/scope_guard/guards/hf.py,sha256=WecW157__LhFQSsMxZk-prv5kw6s_Eyn1ALrFzNNm1s,3965
17
+ orbitals/scope_guard/guards/vllm.py,sha256=SAlY5a-QERA5D6lp5r3L5K86aic9TERKQ9Q8gWIo2xA,8979
18
18
  orbitals/scope_guard/serving/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
19
19
  orbitals/scope_guard/serving/main.py,sha256=ijOtsYOzsbXrgJrWKvNRjL5LmrxbHE74GbwgoXwulA8,3162
20
20
  orbitals/scope_guard/serving/vllm_logging_config.json,sha256=Bc08X8mQWJFAAHEE6ZFVUGnRc77pMVpPvji6BhFTtSE,651
21
- orbitals-0.1.1.dist-info/METADATA,sha256=ot2miZ_tcEGSlultyCrwqHh_Ev5mFGflWhp9KDxn-RI,7347
22
- orbitals-0.1.1.dist-info/WHEEL,sha256=WLgqFyCfm_KASv4WHyYy0P3pM_m7J5L9k2skdKLirC8,87
23
- orbitals-0.1.1.dist-info/entry_points.txt,sha256=fd6lukgEvK9UBwhA1JtcB9MLTqAtntA4H2cc7-nWkeU,51
24
- orbitals-0.1.1.dist-info/licenses/LICENSE,sha256=Eeclrom-K-omYcKnMvijEMV-IMiQ7X-bdgxlZcXcImI,11360
25
- orbitals-0.1.1.dist-info/RECORD,,
21
+ orbitals-0.1.3.dist-info/METADATA,sha256=ld6qaApKgek7fCjkQM_EaRFHnMZI9UHvqoQJH0sF2i8,7643
22
+ orbitals-0.1.3.dist-info/WHEEL,sha256=WLgqFyCfm_KASv4WHyYy0P3pM_m7J5L9k2skdKLirC8,87
23
+ orbitals-0.1.3.dist-info/entry_points.txt,sha256=fd6lukgEvK9UBwhA1JtcB9MLTqAtntA4H2cc7-nWkeU,51
24
+ orbitals-0.1.3.dist-info/licenses/LICENSE,sha256=Eeclrom-K-omYcKnMvijEMV-IMiQ7X-bdgxlZcXcImI,11360
25
+ orbitals-0.1.3.dist-info/RECORD,,