orbitals 0.1.2__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(15000, 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
@@ -152,7 +152,7 @@ class ScopeGuard(BaseScopeGuard):
152
152
  skip_evidences: bool = False,
153
153
  temperature: float = 0.0,
154
154
  max_tokens: int = 3000,
155
- max_model_len: int = 15_000,
155
+ max_model_len: int = 30_000,
156
156
  max_num_seqs: int = 2,
157
157
  ) -> VLLMScopeGuard: ...
158
158
 
@@ -27,7 +27,7 @@ class VLLMScopeGuard(ScopeGuard):
27
27
  skip_evidences: bool = False,
28
28
  temperature: float = 0.0,
29
29
  max_tokens: int = 3000,
30
- max_model_len: int = 15_000,
30
+ max_model_len: int = 30_000,
31
31
  max_num_seqs: int = 2,
32
32
  gpu_memory_utilization: float = 0.9,
33
33
  ):
@@ -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.2
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
@@ -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=tOZbbGoashw-s0V3B5G1DTjQ_giiH6Wn4ii30dAAGrA,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=mZWAvtUq0M9s6yEzlO2r-iYj5vk-VMLe4n6nWSo5pyw,9792
14
+ orbitals/scope_guard/guards/api.py,sha256=d621Cw8kF5251_Mn5kpXCunzrRXVvVb_6JPP1sUlabg,8498
15
+ orbitals/scope_guard/guards/base.py,sha256=13IqwE3a0BtTVOmRnfBHiTuDLi18H7B_YqThCokJ6OY,9792
16
16
  orbitals/scope_guard/guards/hf.py,sha256=WecW157__LhFQSsMxZk-prv5kw6s_Eyn1ALrFzNNm1s,3965
17
- orbitals/scope_guard/guards/vllm.py,sha256=gxMoLOtR23Ky4OQ4UnXblkBnAAxufmM1bik8tHgGAvA,8979
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.2.dist-info/METADATA,sha256=3SWCRK16xMQLr8iY4KXq-QcAH0M2FK9vHP4nbcD8_Cc,7643
22
- orbitals-0.1.2.dist-info/WHEEL,sha256=WLgqFyCfm_KASv4WHyYy0P3pM_m7J5L9k2skdKLirC8,87
23
- orbitals-0.1.2.dist-info/entry_points.txt,sha256=fd6lukgEvK9UBwhA1JtcB9MLTqAtntA4H2cc7-nWkeU,51
24
- orbitals-0.1.2.dist-info/licenses/LICENSE,sha256=Eeclrom-K-omYcKnMvijEMV-IMiQ7X-bdgxlZcXcImI,11360
25
- orbitals-0.1.2.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,,