orbitals 0.0.3__tar.gz → 0.1.1__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.
- orbitals-0.1.1/Dockerfile +23 -0
- orbitals-0.0.3/Dockerfile → orbitals-0.1.1/Dockerfile copy +13 -9
- {orbitals-0.0.3 → orbitals-0.1.1}/PKG-INFO +14 -11
- {orbitals-0.0.3 → orbitals-0.1.1}/README.scope-guard.md +2 -11
- {orbitals-0.0.3 → orbitals-0.1.1}/pyproject.toml +11 -11
- {orbitals-0.0.3 → orbitals-0.1.1}/src/orbitals/scope_guard/serving/main.py +2 -14
- {orbitals-0.0.3 → orbitals-0.1.1}/src/orbitals/utils.py +4 -4
- {orbitals-0.0.3 → orbitals-0.1.1}/src/scripts/push_hf_pipeline.py +2 -9
- {orbitals-0.0.3 → orbitals-0.1.1}/uv.lock +309 -485
- {orbitals-0.0.3 → orbitals-0.1.1}/.dockerignore +0 -0
- {orbitals-0.0.3 → orbitals-0.1.1}/.gitignore +0 -0
- {orbitals-0.0.3 → orbitals-0.1.1}/AGENTS.md +0 -0
- {orbitals-0.0.3 → orbitals-0.1.1}/CONTRIBUTING.md +0 -0
- {orbitals-0.0.3 → orbitals-0.1.1}/LICENSE +0 -0
- {orbitals-0.0.3 → orbitals-0.1.1}/README.md +0 -0
- {orbitals-0.0.3 → orbitals-0.1.1}/assets/orbitals-banner.png +0 -0
- {orbitals-0.0.3 → orbitals-0.1.1}/assets/orbitals.svg +0 -0
- {orbitals-0.0.3 → orbitals-0.1.1}/assets/scope-guard.svg +0 -0
- {orbitals-0.0.3 → orbitals-0.1.1}/examples/scope-guard/api.py +0 -0
- {orbitals-0.0.3 → orbitals-0.1.1}/examples/scope-guard/async_api.py +0 -0
- {orbitals-0.0.3 → orbitals-0.1.1}/examples/scope-guard/local.py +0 -0
- {orbitals-0.0.3 → orbitals-0.1.1}/examples/scope-guard/test.py +0 -0
- {orbitals-0.0.3 → orbitals-0.1.1}/examples/scope-guard/vllm_serve.py +0 -0
- {orbitals-0.0.3 → orbitals-0.1.1}/src/hf_pipeline/scope_guard.py +0 -0
- {orbitals-0.0.3 → orbitals-0.1.1}/src/orbitals/__init__.py +0 -0
- {orbitals-0.0.3 → orbitals-0.1.1}/src/orbitals/cli/__init__.py +0 -0
- {orbitals-0.0.3 → orbitals-0.1.1}/src/orbitals/cli/main.py +0 -0
- {orbitals-0.0.3 → orbitals-0.1.1}/src/orbitals/scope_guard/__init__.py +0 -0
- {orbitals-0.0.3 → orbitals-0.1.1}/src/orbitals/scope_guard/cli/__init__.py +0 -0
- {orbitals-0.0.3 → orbitals-0.1.1}/src/orbitals/scope_guard/cli/convert_default_model_name.py +0 -0
- {orbitals-0.0.3 → orbitals-0.1.1}/src/orbitals/scope_guard/cli/main.py +0 -0
- {orbitals-0.0.3 → orbitals-0.1.1}/src/orbitals/scope_guard/cli/serve.py +0 -0
- {orbitals-0.0.3 → orbitals-0.1.1}/src/orbitals/scope_guard/guards/__init__.py +0 -0
- {orbitals-0.0.3 → orbitals-0.1.1}/src/orbitals/scope_guard/guards/api.py +0 -0
- {orbitals-0.0.3 → orbitals-0.1.1}/src/orbitals/scope_guard/guards/base.py +0 -0
- {orbitals-0.0.3 → orbitals-0.1.1}/src/orbitals/scope_guard/guards/hf.py +0 -0
- {orbitals-0.0.3 → orbitals-0.1.1}/src/orbitals/scope_guard/guards/vllm.py +0 -0
- {orbitals-0.0.3 → orbitals-0.1.1}/src/orbitals/scope_guard/modeling.py +0 -0
- {orbitals-0.0.3 → orbitals-0.1.1}/src/orbitals/scope_guard/prompting.py +0 -0
- {orbitals-0.0.3 → orbitals-0.1.1}/src/orbitals/scope_guard/serving/__init__.py +0 -0
- {orbitals-0.0.3 → orbitals-0.1.1}/src/orbitals/scope_guard/serving/vllm_logging_config.json +0 -0
- {orbitals-0.0.3 → orbitals-0.1.1}/src/orbitals/types.py +0 -0
- {orbitals-0.0.3 → orbitals-0.1.1}/src/scripts/playground.ipynb +0 -0
- {orbitals-0.0.3 → orbitals-0.1.1}/src/scripts/push_model.py +0 -0
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
FROM vllm/vllm-openai:v0.14.1
|
|
2
|
+
|
|
3
|
+
ARG DEBIAN_FRONTEND=noninteractive
|
|
4
|
+
|
|
5
|
+
COPY --from=ghcr.io/astral-sh/uv:0.9.8-debian-slim /usr/local/bin/uv /usr/local/bin/uvx /bin/
|
|
6
|
+
|
|
7
|
+
WORKDIR /app
|
|
8
|
+
ENV PATH="/app/.venv/bin:$PATH"
|
|
9
|
+
ENV UV_COMPILE_BYTECODE=1
|
|
10
|
+
|
|
11
|
+
ARG MODEL
|
|
12
|
+
ENV MODEL=${MODEL}
|
|
13
|
+
|
|
14
|
+
RUN hf download ${MODEL}
|
|
15
|
+
|
|
16
|
+
COPY pyproject.toml uv.lock README.md src /app/src/
|
|
17
|
+
|
|
18
|
+
RUN pip install -e .[serving]
|
|
19
|
+
|
|
20
|
+
EXPOSE 8000
|
|
21
|
+
|
|
22
|
+
ENTRYPOINT ["/bin/bash", "-c"]
|
|
23
|
+
CMD ["orbitals scope-guard serve ${MODEL} --port 8000 --host 0.0.0.0"]
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
FROM
|
|
1
|
+
FROM nvidia/cuda:13.1.1-cudnn-devel-ubuntu24.04 AS builder
|
|
2
2
|
|
|
3
3
|
ARG DEBIAN_FRONTEND=noninteractive
|
|
4
|
-
ARG MODEL
|
|
5
4
|
|
|
6
5
|
COPY --from=ghcr.io/astral-sh/uv:0.9.8-debian-slim /usr/local/bin/uv /usr/local/bin/uvx /bin/
|
|
7
6
|
|
|
@@ -11,7 +10,7 @@ ENV UV_COMPILE_BYTECODE=1
|
|
|
11
10
|
|
|
12
11
|
RUN \
|
|
13
12
|
apt-get update && \
|
|
14
|
-
apt-get install -y --no-install-recommends git
|
|
13
|
+
apt-get install -y --no-install-recommends git python3.12
|
|
15
14
|
|
|
16
15
|
COPY pyproject.toml uv.lock README.md /app/
|
|
17
16
|
|
|
@@ -19,8 +18,8 @@ RUN --mount=type=cache,target=/root/.cache/uv \
|
|
|
19
18
|
uv venv -p 3.12 && \
|
|
20
19
|
uv sync --frozen --extra scope-guard-serve --no-install-project --no-dev
|
|
21
20
|
|
|
22
|
-
|
|
23
|
-
|
|
21
|
+
ARG MODEL
|
|
22
|
+
RUN hf download ${MODEL}
|
|
24
23
|
|
|
25
24
|
COPY src /app/src/
|
|
26
25
|
|
|
@@ -30,13 +29,15 @@ RUN --mount=type=cache,target=/root/.cache/uv \
|
|
|
30
29
|
# TODO remove next line
|
|
31
30
|
ENTRYPOINT ["/bin/bash", "-c"]
|
|
32
31
|
|
|
33
|
-
FROM
|
|
34
|
-
|
|
35
|
-
ARG MODEL
|
|
32
|
+
FROM nvidia/cuda:13.1.1-cudnn-runtime-ubuntu24.04 AS runner
|
|
36
33
|
|
|
37
34
|
WORKDIR /app
|
|
38
35
|
ENV PATH="/app/.venv/bin:$PATH"
|
|
39
36
|
|
|
37
|
+
RUN \
|
|
38
|
+
apt-get update && \
|
|
39
|
+
apt-get install -y --no-install-recommends python3.12
|
|
40
|
+
|
|
40
41
|
COPY --from=builder /app/.venv/ /app/.venv/
|
|
41
42
|
|
|
42
43
|
RUN mkdir -p /root/.cache/huggingface/hub
|
|
@@ -44,5 +45,8 @@ COPY --from=builder /root/.cache/huggingface/hub /root/.cache/huggingface/hub
|
|
|
44
45
|
|
|
45
46
|
EXPOSE 8000
|
|
46
47
|
|
|
48
|
+
ARG MODEL
|
|
49
|
+
ENV MODEL=${MODEL}
|
|
50
|
+
|
|
47
51
|
ENTRYPOINT ["/bin/bash", "-c"]
|
|
48
|
-
CMD [
|
|
52
|
+
CMD ["orbitals scope-guard serve ${MODEL} --port 8000 --host 0.0.0.0"]
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: orbitals
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.1.1
|
|
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:
|
|
14
|
+
Requires-Python: ==3.13
|
|
15
15
|
Requires-Dist: aiohttp
|
|
16
16
|
Requires-Dist: pydantic>=2.0.0
|
|
17
17
|
Requires-Dist: requests
|
|
@@ -19,35 +19,38 @@ Requires-Dist: typer>=0.12.3
|
|
|
19
19
|
Provides-Extra: all
|
|
20
20
|
Requires-Dist: accelerate>=1.11.0; extra == 'all'
|
|
21
21
|
Requires-Dist: fastapi[standard]>=0.119.1; extra == 'all'
|
|
22
|
-
Requires-Dist:
|
|
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
|
|
25
|
+
Requires-Dist: vllm<0.13.0,>=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'
|
|
29
29
|
Requires-Dist: fastapi[standard]>=0.119.1; extra == 'scope-guard-all'
|
|
30
|
-
Requires-Dist:
|
|
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
|
|
33
|
+
Requires-Dist: vllm<0.13.0,>=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'
|
|
37
|
-
Requires-Dist:
|
|
37
|
+
Requires-Dist: nvidia-ml-py; extra == 'scope-guard-hf'
|
|
38
38
|
Requires-Dist: transformers<5.0.0,>=4.47.0; extra == 'scope-guard-hf'
|
|
39
39
|
Provides-Extra: scope-guard-serve
|
|
40
40
|
Requires-Dist: fastapi[standard]>=0.119.1; extra == 'scope-guard-serve'
|
|
41
|
-
Requires-Dist:
|
|
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
|
|
44
|
+
Requires-Dist: vllm<0.13.0,>=0.11.0; extra == 'scope-guard-serve'
|
|
45
45
|
Requires-Dist: xgrammar; extra == 'scope-guard-serve'
|
|
46
46
|
Provides-Extra: scope-guard-vllm
|
|
47
|
-
Requires-Dist:
|
|
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
|
|
49
|
+
Requires-Dist: vllm<0.13.0,>=0.11.0; extra == 'scope-guard-vllm'
|
|
50
50
|
Requires-Dist: xgrammar; extra == 'scope-guard-vllm'
|
|
51
|
+
Provides-Extra: serving
|
|
52
|
+
Requires-Dist: fastapi[standard]>=0.119.1; extra == 'serving'
|
|
53
|
+
Requires-Dist: uvicorn>=0.29.0; extra == 'serving'
|
|
51
54
|
Description-Content-Type: text/markdown
|
|
52
55
|
|
|
53
56
|
<div align="center">
|
|
@@ -282,24 +282,15 @@ pip install orbitals[scope-guard-serve]
|
|
|
282
282
|
orbitals scope-guard serve scope-guard --port 8000
|
|
283
283
|
```
|
|
284
284
|
|
|
285
|
-
Alternatively, we also release a pre-built Docker image:
|
|
286
|
-
|
|
287
|
-
```bash
|
|
288
|
-
docker run --runtime nvidia --gpus all \
|
|
289
|
-
-p 8000:8000 \
|
|
290
|
-
--ipc=host \
|
|
291
|
-
principled-intelligence/scope-guard:0.1.0-scope-guard-4B-q-2601
|
|
292
|
-
```
|
|
293
|
-
|
|
294
285
|
Once the server is running, you can interact with it as follows:
|
|
295
286
|
|
|
296
287
|
#### 1. Direct HTTP Requests
|
|
297
288
|
|
|
298
|
-
Send requests to the `/
|
|
289
|
+
Send requests to the `/orbitals/scope-guard/validate` (or `/orbitals/scope-guard/batch-validatevalidate`) endpoint using cURL or any HTTP client:
|
|
299
290
|
|
|
300
291
|
```bash
|
|
301
292
|
curl -X 'POST' \
|
|
302
|
-
'http://localhost:8000/
|
|
293
|
+
'http://localhost:8000/orbitals/scope-guard/validate' \
|
|
303
294
|
-H 'accept: application/json' \
|
|
304
295
|
-H 'Content-Type: application/json' \
|
|
305
296
|
-d '{
|
|
@@ -4,11 +4,11 @@ build-backend = "hatchling.build"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "orbitals"
|
|
7
|
-
version = "0.
|
|
7
|
+
version = "0.1.1"
|
|
8
8
|
description = "LLM Guardrails tailored to your Principles"
|
|
9
9
|
readme = "README.md"
|
|
10
10
|
|
|
11
|
-
requires-python = "
|
|
11
|
+
requires-python = "==3.13"
|
|
12
12
|
license = { text = "Apache-2.0" }
|
|
13
13
|
|
|
14
14
|
authors = [
|
|
@@ -29,19 +29,19 @@ classifiers = [
|
|
|
29
29
|
dependencies = ["pydantic>=2.0.0", "typer>=0.12.3", "requests", "aiohttp"]
|
|
30
30
|
|
|
31
31
|
[project.optional-dependencies]
|
|
32
|
-
|
|
32
|
+
serving = ["uvicorn>=0.29.0", "fastapi[standard]>=0.119.1"]
|
|
33
|
+
scope-guard-hf = [
|
|
34
|
+
"transformers>=4.47.0,<5.0.0",
|
|
35
|
+
"accelerate>=1.11.0",
|
|
36
|
+
"nvidia-ml-py",
|
|
37
|
+
]
|
|
33
38
|
scope-guard-vllm = [
|
|
34
39
|
"transformers>=4.47.0,<5.0.0",
|
|
35
|
-
"vllm>=0.11.0",
|
|
40
|
+
"vllm>=0.11.0,<0.13.0",
|
|
36
41
|
"xgrammar",
|
|
37
|
-
"
|
|
38
|
-
]
|
|
39
|
-
scope-guard-serve = [
|
|
40
|
-
"orbitals[scope-guard-vllm]",
|
|
41
|
-
"fastapi[standard]>=0.119.1",
|
|
42
|
-
"uvicorn>=0.29.0",
|
|
43
|
-
"vllm>=0.11.0",
|
|
42
|
+
"nvidia-ml-py",
|
|
44
43
|
]
|
|
44
|
+
scope-guard-serve = ["orbitals[scope-guard-vllm]", "orbitals[serving]"]
|
|
45
45
|
scope-guard-all = [
|
|
46
46
|
"orbitals[scope-guard-vllm]",
|
|
47
47
|
"orbitals[scope-guard-hf]",
|
|
@@ -54,19 +54,13 @@ class ScopeGuardResponse(BaseModel):
|
|
|
54
54
|
time_taken: float
|
|
55
55
|
|
|
56
56
|
|
|
57
|
-
@app.post("/
|
|
58
|
-
@app.post("/api/in/scope-classifier/classify", response_model=ScopeGuardResponse)
|
|
57
|
+
@app.post("/orbitals/scope-guard/validate", response_model=ScopeGuardResponse)
|
|
59
58
|
async def validate(
|
|
60
59
|
request: Request,
|
|
61
60
|
conversation: ScopeGuardInput,
|
|
62
61
|
ai_service_description: Annotated[str | AIServiceDescription, Body()],
|
|
63
62
|
skip_evidences: bool | None = Body(None),
|
|
64
63
|
) -> ScopeGuardResponse:
|
|
65
|
-
if request.url.path.endswith("/api/in/scope-classifier/classify"):
|
|
66
|
-
logging.warning(
|
|
67
|
-
"The /api/in/scope-classifier/classify endpoint is deprecated. Please use /api/in/scope-guard/validate instead."
|
|
68
|
-
)
|
|
69
|
-
|
|
70
64
|
global scope_guard
|
|
71
65
|
|
|
72
66
|
start_time = time.time()
|
|
@@ -85,10 +79,9 @@ async def validate(
|
|
|
85
79
|
|
|
86
80
|
|
|
87
81
|
@app.post(
|
|
88
|
-
"/
|
|
82
|
+
"/orbitals/scope-guard/batch-validate",
|
|
89
83
|
response_model=list[ScopeGuardResponse],
|
|
90
84
|
)
|
|
91
|
-
@app.post("/api/in/scope-classifier/batch-classify", response_model=ScopeGuardResponse)
|
|
92
85
|
async def batch_validate(
|
|
93
86
|
request: Request,
|
|
94
87
|
conversations: list[ScopeGuardInput],
|
|
@@ -96,11 +89,6 @@ async def batch_validate(
|
|
|
96
89
|
ai_service_descriptions: list[str] | list[AIServiceDescription] | None = None,
|
|
97
90
|
skip_evidences: bool | None = Body(None),
|
|
98
91
|
) -> list[ScopeGuardResponse]:
|
|
99
|
-
if request.url.path.endswith("/api/in/scope-classifier/batch-classify"):
|
|
100
|
-
logging.warning(
|
|
101
|
-
"The /api/in/scope-classifier/batch-classify endpoint is deprecated. Please use /api/in/scope-guard/batch-validate instead."
|
|
102
|
-
)
|
|
103
|
-
|
|
104
92
|
global scope_guard
|
|
105
93
|
|
|
106
94
|
start_time = time.time()
|
|
@@ -8,7 +8,7 @@ def maybe_configure_gpu_usage():
|
|
|
8
8
|
optimal usage: search for the gpu with the most free memory, and
|
|
9
9
|
set CUDA_VISIBLE_DEVICES to that GPU only.
|
|
10
10
|
|
|
11
|
-
Uses pynvml to avoid triggering CUDA initialization from torch.
|
|
11
|
+
Uses nvidia-ml-py (pynvml) to avoid triggering CUDA initialization from torch.
|
|
12
12
|
"""
|
|
13
13
|
if "CUDA_VISIBLE_DEVICES" in os.environ:
|
|
14
14
|
logging.info(
|
|
@@ -17,15 +17,15 @@ def maybe_configure_gpu_usage():
|
|
|
17
17
|
return
|
|
18
18
|
|
|
19
19
|
try:
|
|
20
|
-
import pynvml # ty: ignore[unresolved-import]
|
|
20
|
+
import pynvml # ty: ignore[unresolved-import] # provided by nvidia-ml-py
|
|
21
21
|
except ModuleNotFoundError:
|
|
22
|
-
logging.debug("
|
|
22
|
+
logging.debug("nvidia-ml-py not available, skipping GPU auto-configuration")
|
|
23
23
|
return
|
|
24
24
|
|
|
25
25
|
try:
|
|
26
26
|
pynvml.nvmlInit()
|
|
27
27
|
except pynvml.NVMLError:
|
|
28
|
-
logging.
|
|
28
|
+
logging.error("NVML initialization failed, skipping GPU auto-configuration")
|
|
29
29
|
return
|
|
30
30
|
|
|
31
31
|
try:
|
|
@@ -5,22 +5,15 @@ from hf_pipeline.scope_guard import ScopeGuardPipeline
|
|
|
5
5
|
|
|
6
6
|
|
|
7
7
|
def main():
|
|
8
|
-
# CUDA_VISIBLE_DEVICES="" PYTHONPATH=$(pwd) python src/scripts/push_hf_pipeline.py
|
|
9
|
-
|
|
10
8
|
PIPELINE_REGISTRY.register_pipeline(
|
|
11
9
|
"scope-guard",
|
|
12
10
|
pipeline_class=ScopeGuardPipeline,
|
|
13
11
|
pt_model=AutoModelForSequenceClassification,
|
|
14
|
-
default={
|
|
15
|
-
"pt": (
|
|
16
|
-
"Qwen/Qwen3-0.6B",
|
|
17
|
-
"c1899de",
|
|
18
|
-
)
|
|
19
|
-
},
|
|
12
|
+
default={"pt": ("principled-intelligence/scope-guard-4B-q-2601", "631addd")},
|
|
20
13
|
)
|
|
21
14
|
|
|
22
15
|
p = pipeline(task="scope-guard")
|
|
23
|
-
p.push_to_hub("principled-intelligence/scope-guard", private=
|
|
16
|
+
p.push_to_hub("principled-intelligence/scope-guard", private=False)
|
|
24
17
|
|
|
25
18
|
|
|
26
19
|
if __name__ == "__main__":
|