raif-vllm 0.1.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.
- raif_vllm-0.1.0/.github/workflows/ci.yml +60 -0
- raif_vllm-0.1.0/.github/workflows/release.yml +139 -0
- raif_vllm-0.1.0/.gitignore +7 -0
- raif_vllm-0.1.0/LICENSE +202 -0
- raif_vllm-0.1.0/PKG-INFO +107 -0
- raif_vllm-0.1.0/README.md +82 -0
- raif_vllm-0.1.0/chat_templates/raif_llama32.jinja +92 -0
- raif_vllm-0.1.0/docs/runpod_testing.md +100 -0
- raif_vllm-0.1.0/docs/vllm_e2e_results.md +214 -0
- raif_vllm-0.1.0/docs/vllm_tool_calling.md +200 -0
- raif_vllm-0.1.0/examples/smoke_plugin.py +239 -0
- raif_vllm-0.1.0/pyproject.toml +81 -0
- raif_vllm-0.1.0/raif_vllm/__init__.py +14 -0
- raif_vllm-0.1.0/raif_vllm/inject.py +69 -0
- raif_vllm-0.1.0/raif_vllm/plugin.py +101 -0
- raif_vllm-0.1.0/raif_vllm/py.typed +0 -0
- raif_vllm-0.1.0/raif_vllm/reasoning.py +195 -0
- raif_vllm-0.1.0/raif_vllm/structured.py +123 -0
- raif_vllm-0.1.0/raif_vllm/tool_parser.py +272 -0
- raif_vllm-0.1.0/scripts/serve_smoke.sh +86 -0
- raif_vllm-0.1.0/tests/test_inject.py +118 -0
- raif_vllm-0.1.0/tests/test_plugin.py +21 -0
- raif_vllm-0.1.0/tests/test_reasoning.py +125 -0
- raif_vllm-0.1.0/tests/test_structured.py +162 -0
- raif_vllm-0.1.0/tests/test_tool_parser.py +161 -0
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
name: CI
|
|
2
|
+
|
|
3
|
+
# Lint + test for the `raif-vllm` plugin. GPU-free: the 3 vLLM-shim tests
|
|
4
|
+
# `importorskip` and skip cleanly on the runner (no vLLM/CUDA), while the pure
|
|
5
|
+
# decode/inject/route/structured logic runs in full. raif-format (>=0.6, with
|
|
6
|
+
# schema_bridge/stream) installs from PyPI as a normal dependency.
|
|
7
|
+
|
|
8
|
+
on:
|
|
9
|
+
push:
|
|
10
|
+
branches: [main]
|
|
11
|
+
pull_request:
|
|
12
|
+
|
|
13
|
+
# Default-deny at the top level. The single job re-grants only read access.
|
|
14
|
+
permissions:
|
|
15
|
+
contents: read
|
|
16
|
+
|
|
17
|
+
concurrency:
|
|
18
|
+
group: ci-${{ github.ref }}
|
|
19
|
+
cancel-in-progress: true
|
|
20
|
+
|
|
21
|
+
jobs:
|
|
22
|
+
test:
|
|
23
|
+
name: Lint & test (py${{ matrix.python-version }})
|
|
24
|
+
runs-on: ubuntu-latest
|
|
25
|
+
permissions:
|
|
26
|
+
contents: read
|
|
27
|
+
strategy:
|
|
28
|
+
fail-fast: false
|
|
29
|
+
matrix:
|
|
30
|
+
python-version: ["3.11", "3.12", "3.13"]
|
|
31
|
+
|
|
32
|
+
steps:
|
|
33
|
+
- name: Harden runner
|
|
34
|
+
# pin to SHA
|
|
35
|
+
uses: step-security/harden-runner@9af89fc71515a100421586dfdb3dc9c984fbf411 # v2.19.4
|
|
36
|
+
with:
|
|
37
|
+
egress-policy: audit
|
|
38
|
+
|
|
39
|
+
- name: Checkout code
|
|
40
|
+
# pin to SHA
|
|
41
|
+
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
|
|
42
|
+
with:
|
|
43
|
+
persist-credentials: false
|
|
44
|
+
|
|
45
|
+
- name: Setup Python ${{ matrix.python-version }}
|
|
46
|
+
# pin to SHA
|
|
47
|
+
uses: actions/setup-python@e9d6f990972a57673cdb72ec29e19d42ba28880f # v6.0.0
|
|
48
|
+
with:
|
|
49
|
+
python-version: ${{ matrix.python-version }}
|
|
50
|
+
|
|
51
|
+
- name: Install the plugin (pulls raif-format>=0.6 from PyPI) + dev deps
|
|
52
|
+
run: |
|
|
53
|
+
python -m pip install --upgrade pip
|
|
54
|
+
python -m pip install . ruff pytest
|
|
55
|
+
|
|
56
|
+
- name: Lint (ruff)
|
|
57
|
+
run: ruff check
|
|
58
|
+
|
|
59
|
+
- name: Test (pytest)
|
|
60
|
+
run: PYTHONPATH=. pytest tests -q
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
name: Release
|
|
2
|
+
|
|
3
|
+
# Release pipeline for the `raif-vllm` package via PyPI Trusted Publishing
|
|
4
|
+
# (OIDC; no long-lived API token). PEP 740 attestations are attached
|
|
5
|
+
# automatically by the publish action under OIDC.
|
|
6
|
+
#
|
|
7
|
+
# Tags `vllm-v*` -> build + publish to PyPI.
|
|
8
|
+
# Branch `release/*` push -> build + publish to TestPyPI (rehearsal).
|
|
9
|
+
#
|
|
10
|
+
# ── ONE-TIME MANUAL SETUP (required before this workflow can publish) ──────────
|
|
11
|
+
# 1. Register the Trusted Publisher on PyPI for project `raif-vllm`:
|
|
12
|
+
# PyPI -> "Publishing" / project settings -> add a GitHub Actions
|
|
13
|
+
# trusted publisher with:
|
|
14
|
+
# Owner: skrrt-sh
|
|
15
|
+
# Repository: raif-vllm
|
|
16
|
+
# Workflow filename: release.yml
|
|
17
|
+
# Environment: pypi
|
|
18
|
+
# Do the same on test.pypi.org with environment `testpypi` (optional).
|
|
19
|
+
# 2. Create the `pypi` (and `testpypi`) GitHub Environments on the repo
|
|
20
|
+
# (Settings -> Environments) and add any desired protection rules.
|
|
21
|
+
# 3. NAME AVAILABILITY: PyPI cannot attach a trusted publisher to a project
|
|
22
|
+
# that does not yet exist. For this brand-new name, use PyPI's "pending
|
|
23
|
+
# publisher" flow (register the publisher before the first upload) so the
|
|
24
|
+
# very first release works over OIDC with no manual token publish.
|
|
25
|
+
#
|
|
26
|
+
# Then release with: git tag vllm-v0.1.0 && git push origin vllm-v0.1.0
|
|
27
|
+
# ──────────────────────────────────────────────────────────────────────────────
|
|
28
|
+
|
|
29
|
+
on:
|
|
30
|
+
push:
|
|
31
|
+
tags:
|
|
32
|
+
- "vllm-v*"
|
|
33
|
+
branches:
|
|
34
|
+
- "release/*"
|
|
35
|
+
|
|
36
|
+
# Default-deny at the top level. Each job re-grants the minimum it needs.
|
|
37
|
+
permissions: {}
|
|
38
|
+
|
|
39
|
+
concurrency:
|
|
40
|
+
group: release-${{ github.ref }}
|
|
41
|
+
cancel-in-progress: false
|
|
42
|
+
|
|
43
|
+
jobs:
|
|
44
|
+
build:
|
|
45
|
+
name: Build sdist + wheel
|
|
46
|
+
runs-on: ubuntu-latest
|
|
47
|
+
permissions:
|
|
48
|
+
contents: read
|
|
49
|
+
|
|
50
|
+
steps:
|
|
51
|
+
- name: Harden runner
|
|
52
|
+
# pin to SHA
|
|
53
|
+
uses: step-security/harden-runner@9af89fc71515a100421586dfdb3dc9c984fbf411 # v2.19.4
|
|
54
|
+
with:
|
|
55
|
+
egress-policy: audit
|
|
56
|
+
|
|
57
|
+
- name: Checkout code
|
|
58
|
+
# pin to SHA
|
|
59
|
+
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
|
|
60
|
+
with:
|
|
61
|
+
persist-credentials: false
|
|
62
|
+
|
|
63
|
+
- name: Setup uv
|
|
64
|
+
# pin to SHA
|
|
65
|
+
uses: astral-sh/setup-uv@e92bafb6253dcd438e0484186d7669ea7a8ca1cc # v6.4.3
|
|
66
|
+
with:
|
|
67
|
+
version: "0.11.14"
|
|
68
|
+
# No action caching in the release pipeline — keep the supply chain lean.
|
|
69
|
+
enable-cache: false
|
|
70
|
+
|
|
71
|
+
- name: Build distributions
|
|
72
|
+
run: uv build
|
|
73
|
+
|
|
74
|
+
- name: Upload distributions
|
|
75
|
+
# pin to SHA
|
|
76
|
+
uses: actions/upload-artifact@330a01c490aca151604b8cf639adc76d48f6c5d4 # v5.0.0
|
|
77
|
+
with:
|
|
78
|
+
name: python-package-distributions
|
|
79
|
+
path: dist/
|
|
80
|
+
|
|
81
|
+
publish-to-testpypi:
|
|
82
|
+
name: Publish to TestPyPI
|
|
83
|
+
needs: build
|
|
84
|
+
if: startsWith(github.ref, 'refs/heads/release/')
|
|
85
|
+
runs-on: ubuntu-latest
|
|
86
|
+
environment: testpypi
|
|
87
|
+
permissions:
|
|
88
|
+
id-token: write # PyPI Trusted Publishing (OIDC)
|
|
89
|
+
contents: read
|
|
90
|
+
|
|
91
|
+
steps:
|
|
92
|
+
- name: Harden runner
|
|
93
|
+
# pin to SHA
|
|
94
|
+
uses: step-security/harden-runner@9af89fc71515a100421586dfdb3dc9c984fbf411 # v2.19.4
|
|
95
|
+
with:
|
|
96
|
+
egress-policy: audit
|
|
97
|
+
|
|
98
|
+
- name: Download distributions
|
|
99
|
+
# pin to SHA
|
|
100
|
+
uses: actions/download-artifact@018cc2cf5baa6db3ef3c5f8a56943fffe632ef53 # v6.0.0
|
|
101
|
+
with:
|
|
102
|
+
name: python-package-distributions
|
|
103
|
+
path: dist/
|
|
104
|
+
|
|
105
|
+
- name: Publish to TestPyPI
|
|
106
|
+
# pin to SHA — Trusted Publishing: no username/password.
|
|
107
|
+
uses: pypa/gh-action-pypi-publish@76f52bc884231f62b9a034ebfe128415bbaabdfc # v1.12.4
|
|
108
|
+
with:
|
|
109
|
+
repository-url: https://test.pypi.org/legacy/
|
|
110
|
+
skip-existing: true
|
|
111
|
+
|
|
112
|
+
publish-to-pypi:
|
|
113
|
+
name: Publish to PyPI
|
|
114
|
+
needs: build
|
|
115
|
+
if: startsWith(github.ref, 'refs/tags/vllm-v')
|
|
116
|
+
runs-on: ubuntu-latest
|
|
117
|
+
environment: pypi
|
|
118
|
+
permissions:
|
|
119
|
+
id-token: write # PyPI Trusted Publishing (OIDC)
|
|
120
|
+
contents: read
|
|
121
|
+
|
|
122
|
+
steps:
|
|
123
|
+
- name: Harden runner
|
|
124
|
+
# pin to SHA
|
|
125
|
+
uses: step-security/harden-runner@9af89fc71515a100421586dfdb3dc9c984fbf411 # v2.19.4
|
|
126
|
+
with:
|
|
127
|
+
egress-policy: audit
|
|
128
|
+
|
|
129
|
+
- name: Download distributions
|
|
130
|
+
# pin to SHA
|
|
131
|
+
uses: actions/download-artifact@018cc2cf5baa6db3ef3c5f8a56943fffe632ef53 # v6.0.0
|
|
132
|
+
with:
|
|
133
|
+
name: python-package-distributions
|
|
134
|
+
path: dist/
|
|
135
|
+
|
|
136
|
+
- name: Publish to PyPI
|
|
137
|
+
# pin to SHA — Trusted Publishing: no username/password. PEP 740
|
|
138
|
+
# attestations are generated and attached automatically under OIDC.
|
|
139
|
+
uses: pypa/gh-action-pypi-publish@76f52bc884231f62b9a034ebfe128415bbaabdfc # v1.12.4
|
raif_vllm-0.1.0/LICENSE
ADDED
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
|
|
2
|
+
Apache License
|
|
3
|
+
Version 2.0, January 2004
|
|
4
|
+
http://www.apache.org/licenses/
|
|
5
|
+
|
|
6
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
7
|
+
|
|
8
|
+
1. Definitions.
|
|
9
|
+
|
|
10
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
11
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
12
|
+
|
|
13
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
14
|
+
the copyright owner that is granting the License.
|
|
15
|
+
|
|
16
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
17
|
+
other entities that control, are controlled by, or are under common
|
|
18
|
+
control with that entity. For the purposes of this definition,
|
|
19
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
20
|
+
direction or management of such entity, whether by contract or
|
|
21
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
22
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
23
|
+
|
|
24
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
25
|
+
exercising permissions granted by this License.
|
|
26
|
+
|
|
27
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
28
|
+
including but not limited to software source code, documentation
|
|
29
|
+
source, and configuration files.
|
|
30
|
+
|
|
31
|
+
"Object" form shall mean any form resulting from mechanical
|
|
32
|
+
transformation or translation of a Source form, including but
|
|
33
|
+
not limited to compiled object code, generated documentation,
|
|
34
|
+
and conversions to other media types.
|
|
35
|
+
|
|
36
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
37
|
+
Object form, made available under the License, as indicated by a
|
|
38
|
+
copyright notice that is included in or attached to the work
|
|
39
|
+
(an example is provided in the Appendix below).
|
|
40
|
+
|
|
41
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
42
|
+
form, that is based on (or derived from) the Work and for which the
|
|
43
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
44
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
45
|
+
of this License, Derivative Works shall not include works that remain
|
|
46
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
47
|
+
the Work and Derivative Works thereof.
|
|
48
|
+
|
|
49
|
+
"Contribution" shall mean any work of authorship, including
|
|
50
|
+
the original version of the Work and any modifications or additions
|
|
51
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
52
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
53
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
54
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
55
|
+
means any form of electronic, verbal, or written communication sent
|
|
56
|
+
to the Licensor or its representatives, including but not limited to
|
|
57
|
+
communication on electronic mailing lists, source code control systems,
|
|
58
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
59
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
60
|
+
excluding communication that is conspicuously marked or otherwise
|
|
61
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
62
|
+
|
|
63
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
64
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
65
|
+
subsequently incorporated within the Work.
|
|
66
|
+
|
|
67
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
68
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
69
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
70
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
71
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
72
|
+
Work and such Derivative Works in Source or Object form.
|
|
73
|
+
|
|
74
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
75
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
76
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
77
|
+
(except as stated in this section) patent license to make, have made,
|
|
78
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
79
|
+
where such license applies only to those patent claims licensable
|
|
80
|
+
by such Contributor that are necessarily infringed by their
|
|
81
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
82
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
83
|
+
institute patent litigation against any entity (including a
|
|
84
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
85
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
86
|
+
or contributory patent infringement, then any patent licenses
|
|
87
|
+
granted to You under this License for that Work shall terminate
|
|
88
|
+
as of the date such litigation is filed.
|
|
89
|
+
|
|
90
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
91
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
92
|
+
modifications, and in Source or Object form, provided that You
|
|
93
|
+
meet the following conditions:
|
|
94
|
+
|
|
95
|
+
(a) You must give any other recipients of the Work or
|
|
96
|
+
Derivative Works a copy of this License; and
|
|
97
|
+
|
|
98
|
+
(b) You must cause any modified files to carry prominent notices
|
|
99
|
+
stating that You changed the files; and
|
|
100
|
+
|
|
101
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
102
|
+
that You distribute, all copyright, patent, trademark, and
|
|
103
|
+
attribution notices from the Source form of the Work,
|
|
104
|
+
excluding those notices that do not pertain to any part of
|
|
105
|
+
the Derivative Works; and
|
|
106
|
+
|
|
107
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
108
|
+
distribution, then any Derivative Works that You distribute must
|
|
109
|
+
include a readable copy of the attribution notices contained
|
|
110
|
+
within such NOTICE file, excluding those notices that do not
|
|
111
|
+
pertain to any part of the Derivative Works, in at least one
|
|
112
|
+
of the following places: within a NOTICE text file distributed
|
|
113
|
+
as part of the Derivative Works; within the Source form or
|
|
114
|
+
documentation, if provided along with the Derivative Works; or,
|
|
115
|
+
within a display generated by the Derivative Works, if and
|
|
116
|
+
wherever such third-party notices normally appear. The contents
|
|
117
|
+
of the NOTICE file are for informational purposes only and
|
|
118
|
+
do not modify the License. You may add Your own attribution
|
|
119
|
+
notices within Derivative Works that You distribute, alongside
|
|
120
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
121
|
+
that such additional attribution notices cannot be construed
|
|
122
|
+
as modifying the License.
|
|
123
|
+
|
|
124
|
+
You may add Your own copyright statement to Your modifications and
|
|
125
|
+
may provide additional or different license terms and conditions
|
|
126
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
127
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
128
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
129
|
+
the conditions stated in this License.
|
|
130
|
+
|
|
131
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
132
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
133
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
134
|
+
this License, without any additional terms or conditions.
|
|
135
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
136
|
+
the terms of any separate license agreement you may have executed
|
|
137
|
+
with Licensor regarding such Contributions.
|
|
138
|
+
|
|
139
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
140
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
141
|
+
except as required for reasonable and customary use in describing the
|
|
142
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
143
|
+
|
|
144
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
145
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
146
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
147
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
148
|
+
implied, including, without limitation, any warranties or conditions
|
|
149
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
150
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
151
|
+
appropriateness of using or redistributing the Work and assume any
|
|
152
|
+
risks associated with Your exercise of permissions under this License.
|
|
153
|
+
|
|
154
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
155
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
156
|
+
unless required by applicable law (such as deliberate and grossly
|
|
157
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
158
|
+
liable to You for damages, including any direct, indirect, special,
|
|
159
|
+
incidental, or consequential damages of any character arising as a
|
|
160
|
+
result of this License or out of the use or inability to use the
|
|
161
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
162
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
163
|
+
other commercial damages or losses), even if such Contributor
|
|
164
|
+
has been advised of the possibility of such damages.
|
|
165
|
+
|
|
166
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
167
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
168
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
169
|
+
or other liability obligations and/or rights consistent with this
|
|
170
|
+
License. However, in accepting such obligations, You may act only
|
|
171
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
172
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
173
|
+
defend, and hold each Contributor harmless for any liability
|
|
174
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
175
|
+
of your accepting any such warranty or additional liability.
|
|
176
|
+
|
|
177
|
+
END OF TERMS AND CONDITIONS
|
|
178
|
+
|
|
179
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
180
|
+
|
|
181
|
+
To apply the Apache License to your work, attach the following
|
|
182
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
183
|
+
replaced with your own identifying information. (Don't include
|
|
184
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
185
|
+
comment syntax for the file format. We also recommend that a
|
|
186
|
+
file or class name and description of purpose be included on the
|
|
187
|
+
same "printed page" as the copyright notice for easier
|
|
188
|
+
identification within third-party archives.
|
|
189
|
+
|
|
190
|
+
Copyright 2026 skrrt-sh
|
|
191
|
+
|
|
192
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
193
|
+
you may not use this file except in compliance with the License.
|
|
194
|
+
You may obtain a copy of the License at
|
|
195
|
+
|
|
196
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
197
|
+
|
|
198
|
+
Unless required by applicable law or agreed to in writing, software
|
|
199
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
200
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
201
|
+
See the License for the specific language governing permissions and
|
|
202
|
+
limitations under the License.
|
raif_vllm-0.1.0/PKG-INFO
ADDED
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: raif-vllm
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: One vLLM plugin for transparent RAIF token savings — install it and existing OpenAI clients get RAIF on tools & response_format with no proxy and no client changes.
|
|
5
|
+
Project-URL: Repository, https://github.com/skrrt-sh/raif-vllm
|
|
6
|
+
Project-URL: Homepage, https://github.com/skrrt-sh/raif-vllm
|
|
7
|
+
Author-email: truehazker <40111175+truehazker@users.noreply.github.com>
|
|
8
|
+
License-Expression: Apache-2.0
|
|
9
|
+
License-File: LICENSE
|
|
10
|
+
Keywords: llm,plugin,raif,response-format,structured-output,tool-call,vllm
|
|
11
|
+
Classifier: Development Status :: 3 - Alpha
|
|
12
|
+
Classifier: Intended Audience :: Developers
|
|
13
|
+
Classifier: Operating System :: OS Independent
|
|
14
|
+
Classifier: Programming Language :: Python :: 3
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
18
|
+
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
19
|
+
Classifier: Typing :: Typed
|
|
20
|
+
Requires-Python: >=3.11
|
|
21
|
+
Requires-Dist: raif-format>=0.6
|
|
22
|
+
Provides-Extra: vllm
|
|
23
|
+
Requires-Dist: vllm<0.20,>=0.19; extra == 'vllm'
|
|
24
|
+
Description-Content-Type: text/markdown
|
|
25
|
+
|
|
26
|
+
# raif-vllm
|
|
27
|
+
|
|
28
|
+
One vLLM plugin for transparent RAIF token savings. Install it and existing
|
|
29
|
+
OpenAI clients get RAIF on `tools` and `response_format` — **no proxy, no client
|
|
30
|
+
changes, no vLLM fork**. The fine-tuned model emits compact RAIF-G; the plugin
|
|
31
|
+
decodes it to JSON at the request/response boundary.
|
|
32
|
+
|
|
33
|
+
## Install
|
|
34
|
+
|
|
35
|
+
`raif-vllm` is not yet on PyPI; install it from the repo (it pulls
|
|
36
|
+
[`raif-format`](https://pypi.org/project/raif-format/) `>=0.6` from PyPI
|
|
37
|
+
automatically):
|
|
38
|
+
|
|
39
|
+
```sh
|
|
40
|
+
pip install "raif-vllm @ git+https://github.com/skrrt-sh/raif-vllm.git"
|
|
41
|
+
# or, from a checkout: pip install -e .
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
vLLM itself is provided by the serving host (it pins CUDA/torch); target
|
|
45
|
+
**`vllm>=0.19,<0.20`** — v0.19 is the last CUDA-12 vLLM and carries the hooks the
|
|
46
|
+
plugin needs. `pip install "raif-vllm[vllm]"` pulls a compatible engine for local
|
|
47
|
+
experiments.
|
|
48
|
+
|
|
49
|
+
## Serve
|
|
50
|
+
|
|
51
|
+
```sh
|
|
52
|
+
VLLM_PLUGINS=raif vllm serve unsloth/Llama-3.2-3B-Instruct \
|
|
53
|
+
--enable-lora --lora-modules raif=skrrt-sh/raif-llama-3.2-3b-lora \
|
|
54
|
+
--max-lora-rank 32 --max-model-len 8192 \
|
|
55
|
+
--chat-template raif_llama32.jinja \
|
|
56
|
+
--reasoning-parser raif \
|
|
57
|
+
--enable-auto-tool-choice --tool-call-parser raif
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
- `VLLM_PLUGINS=raif` runs the entry point, which registers the `raif` reasoning +
|
|
61
|
+
tool parsers **and** installs the `render_chat` inject hook (the seam that adds
|
|
62
|
+
the compact `<schema>` cue before chat-templating).
|
|
63
|
+
- `--tool-call-parser raif` decodes the tools path into `tool_calls`;
|
|
64
|
+
`--reasoning-parser raif` decodes the `response_format` path into
|
|
65
|
+
`message.content`.
|
|
66
|
+
- `--chat-template raif_llama32.jinja` (in `chat_templates/`) is load-bearing: it
|
|
67
|
+
renders messages only and ignores the `tools` variable, so the served prompt
|
|
68
|
+
matches training. Without it the LoRA echoes the verbose OpenAI tool-def JSON.
|
|
69
|
+
|
|
70
|
+
## What a plain OpenAI client gets
|
|
71
|
+
|
|
72
|
+
```python
|
|
73
|
+
from openai import OpenAI
|
|
74
|
+
client = OpenAI(base_url="http://localhost:8000/v1", api_key="EMPTY")
|
|
75
|
+
|
|
76
|
+
# tools -> JSON tool_calls
|
|
77
|
+
client.chat.completions.create(model="raif", tools=[...], tool_choice="auto",
|
|
78
|
+
messages=[{"role": "user", "content": "Weather in Oslo?"}])
|
|
79
|
+
|
|
80
|
+
# response_format -> JSON content (use non-streaming — see below)
|
|
81
|
+
client.chat.completions.create(model="raif",
|
|
82
|
+
response_format={"type": "json_schema", "json_schema": {...}},
|
|
83
|
+
messages=[{"role": "user", "content": "..."}])
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
| OpenAI path | Behavior |
|
|
87
|
+
|---|---|
|
|
88
|
+
| plain chat | passthrough, untouched |
|
|
89
|
+
| `tools` | RAIF-G → JSON `tool_calls` (streaming + non-streaming) |
|
|
90
|
+
| `response_format` (`json_schema` / `json_object`) | RAIF-G → JSON `message.content` |
|
|
91
|
+
| plain chat **streaming** | passthrough |
|
|
92
|
+
|
|
93
|
+
### Known limitation: streaming `response_format`
|
|
94
|
+
|
|
95
|
+
Streaming a `response_format` request is **not decoded** — the client receives raw
|
|
96
|
+
RAIF-G. (vLLM's streaming seam passes the parser no schema, and the shared
|
|
97
|
+
`is_reasoning_end` flag must stay `True` so the *tools* streaming path keeps
|
|
98
|
+
working.) **Use non-streaming `response_format` for structured output** — it
|
|
99
|
+
decodes fully. Tool-call streaming is unaffected. See
|
|
100
|
+
[`docs/vllm_e2e_results.md`](docs/vllm_e2e_results.md).
|
|
101
|
+
|
|
102
|
+
## More
|
|
103
|
+
|
|
104
|
+
- End-to-end GPU smoke: [`scripts/serve_smoke.sh`](scripts/serve_smoke.sh) + [`examples/smoke_plugin.py`](examples/smoke_plugin.py).
|
|
105
|
+
- Serving guide + the chat-template fix: [`docs/vllm_tool_calling.md`](docs/vllm_tool_calling.md).
|
|
106
|
+
- RunPod runbook: [`docs/runpod_testing.md`](docs/runpod_testing.md).
|
|
107
|
+
- The model: the [`skrrt-sh/raif-llama-3.2-3b-lora`](https://huggingface.co/skrrt-sh/raif-llama-3.2-3b-lora) adapter, trained in [`skrrt-sh/raif-lora`](https://github.com/skrrt-sh/raif-lora). The codec: [`raif-format`](https://github.com/skrrt-sh/raif-standard).
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
# raif-vllm
|
|
2
|
+
|
|
3
|
+
One vLLM plugin for transparent RAIF token savings. Install it and existing
|
|
4
|
+
OpenAI clients get RAIF on `tools` and `response_format` — **no proxy, no client
|
|
5
|
+
changes, no vLLM fork**. The fine-tuned model emits compact RAIF-G; the plugin
|
|
6
|
+
decodes it to JSON at the request/response boundary.
|
|
7
|
+
|
|
8
|
+
## Install
|
|
9
|
+
|
|
10
|
+
`raif-vllm` is not yet on PyPI; install it from the repo (it pulls
|
|
11
|
+
[`raif-format`](https://pypi.org/project/raif-format/) `>=0.6` from PyPI
|
|
12
|
+
automatically):
|
|
13
|
+
|
|
14
|
+
```sh
|
|
15
|
+
pip install "raif-vllm @ git+https://github.com/skrrt-sh/raif-vllm.git"
|
|
16
|
+
# or, from a checkout: pip install -e .
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
vLLM itself is provided by the serving host (it pins CUDA/torch); target
|
|
20
|
+
**`vllm>=0.19,<0.20`** — v0.19 is the last CUDA-12 vLLM and carries the hooks the
|
|
21
|
+
plugin needs. `pip install "raif-vllm[vllm]"` pulls a compatible engine for local
|
|
22
|
+
experiments.
|
|
23
|
+
|
|
24
|
+
## Serve
|
|
25
|
+
|
|
26
|
+
```sh
|
|
27
|
+
VLLM_PLUGINS=raif vllm serve unsloth/Llama-3.2-3B-Instruct \
|
|
28
|
+
--enable-lora --lora-modules raif=skrrt-sh/raif-llama-3.2-3b-lora \
|
|
29
|
+
--max-lora-rank 32 --max-model-len 8192 \
|
|
30
|
+
--chat-template raif_llama32.jinja \
|
|
31
|
+
--reasoning-parser raif \
|
|
32
|
+
--enable-auto-tool-choice --tool-call-parser raif
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
- `VLLM_PLUGINS=raif` runs the entry point, which registers the `raif` reasoning +
|
|
36
|
+
tool parsers **and** installs the `render_chat` inject hook (the seam that adds
|
|
37
|
+
the compact `<schema>` cue before chat-templating).
|
|
38
|
+
- `--tool-call-parser raif` decodes the tools path into `tool_calls`;
|
|
39
|
+
`--reasoning-parser raif` decodes the `response_format` path into
|
|
40
|
+
`message.content`.
|
|
41
|
+
- `--chat-template raif_llama32.jinja` (in `chat_templates/`) is load-bearing: it
|
|
42
|
+
renders messages only and ignores the `tools` variable, so the served prompt
|
|
43
|
+
matches training. Without it the LoRA echoes the verbose OpenAI tool-def JSON.
|
|
44
|
+
|
|
45
|
+
## What a plain OpenAI client gets
|
|
46
|
+
|
|
47
|
+
```python
|
|
48
|
+
from openai import OpenAI
|
|
49
|
+
client = OpenAI(base_url="http://localhost:8000/v1", api_key="EMPTY")
|
|
50
|
+
|
|
51
|
+
# tools -> JSON tool_calls
|
|
52
|
+
client.chat.completions.create(model="raif", tools=[...], tool_choice="auto",
|
|
53
|
+
messages=[{"role": "user", "content": "Weather in Oslo?"}])
|
|
54
|
+
|
|
55
|
+
# response_format -> JSON content (use non-streaming — see below)
|
|
56
|
+
client.chat.completions.create(model="raif",
|
|
57
|
+
response_format={"type": "json_schema", "json_schema": {...}},
|
|
58
|
+
messages=[{"role": "user", "content": "..."}])
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
| OpenAI path | Behavior |
|
|
62
|
+
|---|---|
|
|
63
|
+
| plain chat | passthrough, untouched |
|
|
64
|
+
| `tools` | RAIF-G → JSON `tool_calls` (streaming + non-streaming) |
|
|
65
|
+
| `response_format` (`json_schema` / `json_object`) | RAIF-G → JSON `message.content` |
|
|
66
|
+
| plain chat **streaming** | passthrough |
|
|
67
|
+
|
|
68
|
+
### Known limitation: streaming `response_format`
|
|
69
|
+
|
|
70
|
+
Streaming a `response_format` request is **not decoded** — the client receives raw
|
|
71
|
+
RAIF-G. (vLLM's streaming seam passes the parser no schema, and the shared
|
|
72
|
+
`is_reasoning_end` flag must stay `True` so the *tools* streaming path keeps
|
|
73
|
+
working.) **Use non-streaming `response_format` for structured output** — it
|
|
74
|
+
decodes fully. Tool-call streaming is unaffected. See
|
|
75
|
+
[`docs/vllm_e2e_results.md`](docs/vllm_e2e_results.md).
|
|
76
|
+
|
|
77
|
+
## More
|
|
78
|
+
|
|
79
|
+
- End-to-end GPU smoke: [`scripts/serve_smoke.sh`](scripts/serve_smoke.sh) + [`examples/smoke_plugin.py`](examples/smoke_plugin.py).
|
|
80
|
+
- Serving guide + the chat-template fix: [`docs/vllm_tool_calling.md`](docs/vllm_tool_calling.md).
|
|
81
|
+
- RunPod runbook: [`docs/runpod_testing.md`](docs/runpod_testing.md).
|
|
82
|
+
- The model: the [`skrrt-sh/raif-llama-3.2-3b-lora`](https://huggingface.co/skrrt-sh/raif-llama-3.2-3b-lora) adapter, trained in [`skrrt-sh/raif-lora`](https://github.com/skrrt-sh/raif-lora). The codec: [`raif-format`](https://github.com/skrrt-sh/raif-standard).
|