Skip to content

Commit eb86106

Browse files
authored
Merge branch 'main' into main
2 parents 57afd6f + 64bca4c commit eb86106

File tree

6 files changed

+27
-20
lines changed

6 files changed

+27
-20
lines changed

.github/workflows/CI.yml

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -28,21 +28,20 @@ jobs:
2828
target: x86_64
2929
- runner: ubuntu-22.04
3030
target: x86
31-
# - runner: ubuntu-22.04
32-
# target: aarch64
31+
- runner: ubuntu-22.04
32+
target: aarch64
3333
- runner: ubuntu-22.04
3434
target: armv7
35-
# - runner: ubuntu-22.04
36-
# target: s390x
37-
# - runner: ubuntu-22.04
38-
# target: ppc64le
3935
steps:
4036
- uses: actions/checkout@v4
4137
- uses: actions/setup-python@v5
4238
with:
4339
python-version: 3.x
4440
- name: Build wheels
4541
uses: PyO3/maturin-action@v1
42+
env:
43+
# Ensure ring's ARM assembly sees an explicit architecture on aarch64 (glibc)
44+
CFLAGS_aarch64_unknown_linux_gnu: -D__ARM_ARCH=8
4645
with:
4746
target: ${{ matrix.platform.target }}
4847
args: --release --out dist --find-interpreter
@@ -74,6 +73,9 @@ jobs:
7473
python-version: 3.x
7574
- name: Build wheels
7675
uses: PyO3/maturin-action@v1
76+
env:
77+
# Ensure ring's ARM assembly sees an explicit architecture on aarch64 (musl)
78+
CFLAGS_aarch64_unknown_linux_musl: -D__ARM_ARCH=8
7779
with:
7880
target: ${{ matrix.platform.target }}
7981
args: --release --out dist --find-interpreter
@@ -104,7 +106,7 @@ jobs:
104106
uses: PyO3/maturin-action@v1
105107
with:
106108
target: ${{ matrix.platform.target }}
107-
args: -F python-binding --release --out dist --find-interpreter
109+
args: --release --out dist --find-interpreter
108110
sccache: ${{ !startsWith(github.ref, 'refs/tags/') }}
109111
- name: Upload wheels
110112
uses: actions/upload-artifact@v4
@@ -130,7 +132,7 @@ jobs:
130132
uses: PyO3/maturin-action@v1
131133
with:
132134
target: ${{ matrix.platform.target }}
133-
args: -F python-binding --release --out dist --find-interpreter
135+
args: --release --out dist --find-interpreter
134136
sccache: ${{ !startsWith(github.ref, 'refs/tags/') }}
135137
- name: Upload wheels
136138
uses: actions/upload-artifact@v4

Cargo.toml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,10 @@ reqwest = { version = "0.12.5", default-features = false, features = [
4242
] }
4343
futures = "0.3"
4444
clap = { version = "4", features = ["derive"] }
45-
pyo3 = { version = "0.25.0", optional = true, features = ["extension-module"] }
45+
pyo3 = { version = "0.25.0", optional = true, features = [
46+
"extension-module",
47+
"abi3-py38",
48+
] }
4649
wasm-bindgen = { version = "0.2.100", optional = true, features = [
4750
"serde-serialize",
4851
] }

README.md

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@
1010

1111
The [gpt-oss models][gpt-oss] were trained on the [harmony response format][harmony-format] for defining conversation structures, generating reasoning output and structuring function calls. If you are not using gpt-oss directly but through an API or a provider like HuggingFace, Ollama, or vLLM, you will not have to be concerned about this as your inference solution will handle the formatting. If you are building your own inference solution, this guide will walk you through the prompt format. The format is designed to mimic the OpenAI Responses API, so if you have used that API before, this format should hopefully feel familiar to you. gpt-oss should not be used without using the harmony format as it will not work correctly.
1212

13-
The format enables the model to output to multiple different channels for chain of thought, and tool calling premables along with regular responses. It also enables specifying various tool namespaces, and structured outputs along with a clear instruction hierarchy. [Check out the guide][harmony-format] to learn more about the format itself.
13+
The format enables the model to output to multiple different channels for chain of thought, and tool calling preambles along with regular responses. It also enables specifying various tool namespaces, and structured outputs along with a clear instruction hierarchy. [Check out the guide][harmony-format] to learn more about the format itself.
1414

15-
```
15+
```text
1616
<|start|>system<|message|>You are ChatGPT, a large language model trained by OpenAI.
1717
Knowledge cutoff: 2024-06
1818
Current date: 2025-06-28
@@ -114,11 +114,11 @@ openai-harmony = { git = "https://github.com/openai/harmony" }
114114
```rust
115115
use openai_harmony::chat::{Message, Role, Conversation};
116116
use openai_harmony::{HarmonyEncodingName, load_harmony_encoding};
117+
117118
fn main() -> anyhow::Result<()> {
118119
let enc = load_harmony_encoding(HarmonyEncodingName::HarmonyGptOss)?;
119-
let convo = Conversation::from_messages([
120-
Message::from_role_and_content(Role::User, "Hello there!"),
121-
]);
120+
let convo =
121+
Conversation::from_messages([Message::from_role_and_content(Role::User, "Hello there!")]);
122122
let tokens = enc.render_conversation_for_completion(&convo, Role::Assistant, None)?;
123123
println!("{:?}", tokens);
124124
Ok(())
@@ -130,7 +130,7 @@ fn main() -> anyhow::Result<()> {
130130
The majority of the rendering and parsing is built in Rust for performance and exposed to Python
131131
through thin [`pyo3`](https://pyo3.rs/) bindings.
132132

133-
```
133+
```text
134134
┌──────────────────┐ ┌───────────────────────────┐
135135
│ Python code │ │ Rust core (this repo) │
136136
│ (dataclasses, │────► │ • chat / encoding logic │
@@ -140,7 +140,7 @@ through thin [`pyo3`](https://pyo3.rs/) bindings.
140140

141141
### Repository layout
142142

143-
```
143+
```text
144144
.
145145
├── src/ # Rust crate
146146
│ ├── chat.rs # High-level data-structures (Role, Message, …)
@@ -177,10 +177,10 @@ source .venv/bin/activate
177177
# Install maturin and test dependencies
178178
pip install maturin pytest mypy ruff # tailor to your workflow
179179
# Compile the Rust crate *and* install the Python package in editable mode
180-
maturin develop -F python-binding --release
180+
maturin develop --release
181181
```
182182

183-
`maturin develop -F python-binding` builds _harmony_ with Cargo, produces a native extension
183+
`maturin develop` builds _harmony_ with Cargo, produces a native extension
184184
(`openai_harmony.<abi>.so`) and places it in your virtualenv next to the pure-
185185
Python wrapper – similar to `pip install -e .` for pure Python projects.
186186

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ readme = "README.md"
1919
demo = ["uvicorn", "fastapi"]
2020

2121
[tool.maturin]
22-
features = ["pyo3/extension-module"]
22+
features = ["python-binding", "pyo3/extension-module"]
2323
module-name = "openai_harmony"
2424
python-source = "python"
2525

src/lib.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
#![doc = include_str!("../README.md")]
2+
13
pub mod chat;
24
mod encoding;
35
mod registry;

test_python.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#!/usr/bin/env bash
22
set -e
33
source .venv/bin/activate
4-
maturin develop -F python-binding --release
4+
maturin develop --release
55
pytest "$@"

0 commit comments

Comments
 (0)