tiles-harmony 0.0.8rc4__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.
Files changed (73) hide show
  1. tiles_harmony-0.0.8rc4/.github/actions/run-rust-python-tests/action.yml +69 -0
  2. tiles_harmony-0.0.8rc4/.github/workflows/CI.yml +222 -0
  3. tiles_harmony-0.0.8rc4/.gitignore +75 -0
  4. tiles_harmony-0.0.8rc4/AGENTS.md +9 -0
  5. tiles_harmony-0.0.8rc4/Cargo.lock +2940 -0
  6. tiles_harmony-0.0.8rc4/Cargo.toml +57 -0
  7. tiles_harmony-0.0.8rc4/LICENSE +202 -0
  8. tiles_harmony-0.0.8rc4/PKG-INFO +234 -0
  9. tiles_harmony-0.0.8rc4/README.md +218 -0
  10. tiles_harmony-0.0.8rc4/demo/harmony-demo/.gitignore +44 -0
  11. tiles_harmony-0.0.8rc4/demo/harmony-demo/README.md +36 -0
  12. tiles_harmony-0.0.8rc4/demo/harmony-demo/components.json +21 -0
  13. tiles_harmony-0.0.8rc4/demo/harmony-demo/next.config.ts +30 -0
  14. tiles_harmony-0.0.8rc4/demo/harmony-demo/package-lock.json +2376 -0
  15. tiles_harmony-0.0.8rc4/demo/harmony-demo/package.json +37 -0
  16. tiles_harmony-0.0.8rc4/demo/harmony-demo/postcss.config.mjs +5 -0
  17. tiles_harmony-0.0.8rc4/demo/harmony-demo/public/openai_logo.svg +21 -0
  18. tiles_harmony-0.0.8rc4/demo/harmony-demo/src/app/favicon.ico +0 -0
  19. tiles_harmony-0.0.8rc4/demo/harmony-demo/src/app/globals.css +196 -0
  20. tiles_harmony-0.0.8rc4/demo/harmony-demo/src/app/layout.tsx +22 -0
  21. tiles_harmony-0.0.8rc4/demo/harmony-demo/src/app/page.tsx +14 -0
  22. tiles_harmony-0.0.8rc4/demo/harmony-demo/src/components/HarmonyDemo.tsx +487 -0
  23. tiles_harmony-0.0.8rc4/demo/harmony-demo/src/components/ui/button.tsx +59 -0
  24. tiles_harmony-0.0.8rc4/demo/harmony-demo/src/components/ui/collapsible.tsx +33 -0
  25. tiles_harmony-0.0.8rc4/demo/harmony-demo/src/components/ui/label.tsx +24 -0
  26. tiles_harmony-0.0.8rc4/demo/harmony-demo/src/components/ui/switch.tsx +31 -0
  27. tiles_harmony-0.0.8rc4/demo/harmony-demo/src/components/ui/tooltip.tsx +61 -0
  28. tiles_harmony-0.0.8rc4/demo/harmony-demo/src/lib/utils.ts +6 -0
  29. tiles_harmony-0.0.8rc4/demo/harmony-demo/tsconfig.json +27 -0
  30. tiles_harmony-0.0.8rc4/docs/format.md +602 -0
  31. tiles_harmony-0.0.8rc4/docs/header.png +0 -0
  32. tiles_harmony-0.0.8rc4/docs/python.md +181 -0
  33. tiles_harmony-0.0.8rc4/docs/rust.md +167 -0
  34. tiles_harmony-0.0.8rc4/javascript/README.md +9 -0
  35. tiles_harmony-0.0.8rc4/javascript/package.json +11 -0
  36. tiles_harmony-0.0.8rc4/pyproject.toml +28 -0
  37. tiles_harmony-0.0.8rc4/python/openai_harmony/__init__.py +732 -0
  38. tiles_harmony-0.0.8rc4/run_checks.sh +8 -0
  39. tiles_harmony-0.0.8rc4/src/chat.rs +535 -0
  40. tiles_harmony-0.0.8rc4/src/encoding.rs +1594 -0
  41. tiles_harmony-0.0.8rc4/src/lib.rs +20 -0
  42. tiles_harmony-0.0.8rc4/src/py_module.rs +435 -0
  43. tiles_harmony-0.0.8rc4/src/registry.rs +130 -0
  44. tiles_harmony-0.0.8rc4/src/tests.rs +933 -0
  45. tiles_harmony-0.0.8rc4/src/tiktoken.rs +525 -0
  46. tiles_harmony-0.0.8rc4/src/tiktoken_ext/mod.rs +2 -0
  47. tiles_harmony-0.0.8rc4/src/tiktoken_ext/public_encodings.rs +575 -0
  48. tiles_harmony-0.0.8rc4/src/wasm_module.rs +376 -0
  49. tiles_harmony-0.0.8rc4/test-data/test_browser_and_function_tool.txt +61 -0
  50. tiles_harmony-0.0.8rc4/test-data/test_browser_and_python_tool.txt +55 -0
  51. tiles_harmony-0.0.8rc4/test-data/test_browser_tool_only.txt +49 -0
  52. tiles_harmony-0.0.8rc4/test-data/test_does_not_drop_if_ongoing_analysis.txt +1 -0
  53. tiles_harmony-0.0.8rc4/test-data/test_dropping_cot_by_default.txt +1 -0
  54. tiles_harmony-0.0.8rc4/test-data/test_keep_analysis_between_finals.txt +1 -0
  55. tiles_harmony-0.0.8rc4/test-data/test_no_tools.txt +7 -0
  56. tiles_harmony-0.0.8rc4/test-data/test_preserve_cot.txt +1 -0
  57. tiles_harmony-0.0.8rc4/test-data/test_reasoning_system_message.txt +6 -0
  58. tiles_harmony-0.0.8rc4/test-data/test_reasoning_system_message_no_instruction.txt +6 -0
  59. tiles_harmony-0.0.8rc4/test-data/test_reasoning_system_message_with_dates.txt +7 -0
  60. tiles_harmony-0.0.8rc4/test-data/test_render_functions_with_parameters.txt +56 -0
  61. tiles_harmony-0.0.8rc4/test-data/test_simple_convo.txt +6 -0
  62. tiles_harmony-0.0.8rc4/test-data/test_simple_convo_high_effort.txt +8 -0
  63. tiles_harmony-0.0.8rc4/test-data/test_simple_convo_high_effort_no_instruction.txt +6 -0
  64. tiles_harmony-0.0.8rc4/test-data/test_simple_convo_low_effort.txt +8 -0
  65. tiles_harmony-0.0.8rc4/test-data/test_simple_convo_low_effort_no_instruction.txt +6 -0
  66. tiles_harmony-0.0.8rc4/test-data/test_simple_convo_medium_effort.txt +8 -0
  67. tiles_harmony-0.0.8rc4/test-data/test_simple_convo_medium_effort_no_instruction.txt +6 -0
  68. tiles_harmony-0.0.8rc4/test-data/test_simple_reasoning_response.txt +4 -0
  69. tiles_harmony-0.0.8rc4/test-data/test_simple_tool_call.txt +4 -0
  70. tiles_harmony-0.0.8rc4/test-data/test_streamable_parser.txt +2 -0
  71. tiles_harmony-0.0.8rc4/test-data/test_tool_response_parsing.txt +1 -0
  72. tiles_harmony-0.0.8rc4/test_python.sh +6 -0
  73. tiles_harmony-0.0.8rc4/tests/test_harmony.py +1257 -0
@@ -0,0 +1,69 @@
1
+ name: Run Rust and Python tests
2
+
3
+ description: Format, clippy, Rust tests (incl. doctests), build Python extension and run pytest
4
+
5
+ inputs:
6
+ python-version:
7
+ description: Python version to use
8
+ required: false
9
+ default: "3.11"
10
+ rust-toolchain:
11
+ description: Rust toolchain channel
12
+ required: false
13
+ default: stable
14
+
15
+ runs:
16
+ using: composite
17
+ steps:
18
+ - name: Setup Rust toolchain
19
+ uses: dtolnay/rust-toolchain@29eef336d9b2848a0b548edc03f92a220660cdb8 # stable
20
+ with:
21
+ toolchain: ${{ inputs.rust-toolchain }}
22
+ components: clippy,rustfmt
23
+
24
+ - name: Setup Python
25
+ uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5
26
+ with:
27
+ python-version: ${{ inputs.python-version }}
28
+
29
+ - name: Upgrade pip
30
+ shell: bash
31
+ run: |
32
+ python -m pip install --upgrade pip
33
+
34
+ - name: Install test deps
35
+ shell: bash
36
+ run: |
37
+ python -m pip install pytest
38
+
39
+ - name: Check rustfmt
40
+ shell: bash
41
+ run: |
42
+ cargo fmt --all --check
43
+
44
+ - name: Run clippy
45
+ shell: bash
46
+ run: |
47
+ cargo clippy --all-targets --all-features -- -D warnings
48
+
49
+ - name: Run Rust tests (unit/integration)
50
+ shell: bash
51
+ run: |
52
+ cargo test --all-targets --all-features
53
+
54
+ - name: Run Rust doctests
55
+ shell: bash
56
+ run: |
57
+ cargo test --doc
58
+
59
+ - name: Build and install Python package
60
+ shell: bash
61
+ run: |
62
+ pip install .
63
+
64
+ - name: Run pytest
65
+ shell: bash
66
+ env:
67
+ PYTHONUTF8: "1"
68
+ run: |
69
+ pytest -q
@@ -0,0 +1,222 @@
1
+ # This file is autogenerated by maturin v1.8.7
2
+ # To update, run
3
+ #
4
+ # maturin generate-ci github
5
+ #
6
+ name: CI
7
+
8
+ on:
9
+ push:
10
+ branches:
11
+ - main
12
+ - master
13
+ tags:
14
+ - "*"
15
+ pull_request:
16
+ workflow_dispatch:
17
+
18
+ permissions:
19
+ contents: read
20
+
21
+ jobs:
22
+ tests:
23
+ name: Tests (fmt, clippy, cargo test, doctest, pytest)
24
+ runs-on: ${{ matrix.os }}
25
+ strategy:
26
+ fail-fast: false
27
+ matrix:
28
+ os: [ubuntu-latest, macos-14]
29
+
30
+
31
+ python-version: ["3.11", "3.12", "3.13"]
32
+ steps:
33
+ - uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
34
+ - name: Run composite test suite
35
+ uses: ./.github/actions/run-rust-python-tests
36
+ with:
37
+ python-version: ${{ matrix.python-version }}
38
+ rust-toolchain: stable
39
+
40
+ linux:
41
+ needs: [tests]
42
+ runs-on: ${{ matrix.platform.runner }}
43
+ strategy:
44
+ matrix:
45
+ platform:
46
+ - runner: ubuntu-22.04
47
+ target: x86_64
48
+ - runner: ubuntu-22.04
49
+ target: x86
50
+ # - runner: ubuntu-22.04
51
+ # target: aarch64
52
+ # - runner: ubuntu-22.04
53
+ # target: armv7
54
+ # - runner: ubuntu-22.04
55
+ # target: ppc64le
56
+ steps:
57
+ - uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
58
+ - uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5
59
+ with:
60
+ python-version: 3.x
61
+ - name: Build wheels
62
+ uses: PyO3/maturin-action@db323e2cf5679b7feb8bcb561a36b27a0bc19e79 # v1
63
+ env:
64
+ # Ensure ring's ARM assembly sees an explicit architecture on aarch64 (glibc)
65
+ CFLAGS_aarch64_unknown_linux_gnu: -D__ARM_ARCH=8
66
+ with:
67
+ target: ${{ matrix.platform.target }}
68
+ args: --release --out dist --find-interpreter
69
+ sccache: ${{ !startsWith(github.ref, 'refs/tags/') }}
70
+ manylinux: auto
71
+ - name: Upload wheels
72
+ if: ${{ startsWith(github.ref, 'refs/tags/') || github.event_name == 'workflow_dispatch' }}
73
+ uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4
74
+ with:
75
+ name: wheels-linux-${{ matrix.platform.target }}
76
+ path: dist
77
+
78
+ musllinux:
79
+ needs: [tests]
80
+ runs-on: ${{ matrix.platform.runner }}
81
+ strategy:
82
+ matrix:
83
+ platform:
84
+ - runner: ubuntu-22.04
85
+ target: x86_64
86
+ - runner: ubuntu-22.04
87
+ target: x86
88
+ - runner: ubuntu-22.04
89
+ target: aarch64
90
+ - runner: ubuntu-22.04
91
+ target: armv7
92
+ steps:
93
+ - uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
94
+ - uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5
95
+ with:
96
+ python-version: 3.x
97
+ - name: Build wheels
98
+ uses: PyO3/maturin-action@db323e2cf5679b7feb8bcb561a36b27a0bc19e79 # v1
99
+ env:
100
+ # Ensure ring's ARM assembly sees an explicit architecture on aarch64 (musl)
101
+ CFLAGS_aarch64_unknown_linux_musl: -D__ARM_ARCH=8
102
+ with:
103
+ target: ${{ matrix.platform.target }}
104
+ args: --release --out dist --find-interpreter
105
+ sccache: ${{ !startsWith(github.ref, 'refs/tags/') }}
106
+ manylinux: musllinux_1_2
107
+ - name: Upload wheels
108
+ if: ${{ startsWith(github.ref, 'refs/tags/') || github.event_name == 'workflow_dispatch' }}
109
+ uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4
110
+ with:
111
+ name: wheels-musllinux-${{ matrix.platform.target }}
112
+ path: dist
113
+
114
+ windows:
115
+ needs: [tests]
116
+ runs-on: ${{ matrix.platform.runner }}
117
+ strategy:
118
+ matrix:
119
+ platform:
120
+ - runner: windows-latest
121
+ target: x64
122
+ - runner: windows-latest
123
+ target: x86
124
+ steps:
125
+ - uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
126
+ - uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5
127
+ with:
128
+ python-version: 3.x
129
+ architecture: ${{ matrix.platform.target }}
130
+ - name: Build wheels
131
+ uses: PyO3/maturin-action@db323e2cf5679b7feb8bcb561a36b27a0bc19e79 # v1
132
+ with:
133
+ target: ${{ matrix.platform.target }}
134
+ args: --release --out dist --find-interpreter
135
+ sccache: ${{ !startsWith(github.ref, 'refs/tags/') }}
136
+ - name: Upload wheels
137
+ if: ${{ startsWith(github.ref, 'refs/tags/') || github.event_name == 'workflow_dispatch' }}
138
+ uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4
139
+ with:
140
+ name: wheels-windows-${{ matrix.platform.target }}
141
+ path: dist
142
+
143
+ macos:
144
+ needs: [tests]
145
+ runs-on: ${{ matrix.platform.runner }}
146
+ strategy:
147
+ matrix:
148
+ platform:
149
+ - runner: macos-14
150
+ target: aarch64
151
+ - runner: macos-15
152
+ target: aarch64
153
+ steps:
154
+ - uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
155
+ - uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5
156
+ with:
157
+ python-version: 3.x
158
+ - name: Build wheels
159
+ uses: PyO3/maturin-action@db323e2cf5679b7feb8bcb561a36b27a0bc19e79 # v1
160
+ with:
161
+ target: ${{ matrix.platform.target }}
162
+ args: --release --out dist --find-interpreter
163
+ sccache: ${{ !startsWith(github.ref, 'refs/tags/') }}
164
+ - name: Upload wheels
165
+ if: ${{ startsWith(github.ref, 'refs/tags/') || github.event_name == 'workflow_dispatch' }}
166
+ uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4
167
+ with:
168
+ name: wheels-macos-${{ matrix.platform.runner }}-${{ matrix.platform.target }}
169
+ path: dist
170
+
171
+ sdist:
172
+ needs: [tests]
173
+ runs-on: ubuntu-latest
174
+ steps:
175
+ - uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
176
+ - name: Build sdist
177
+ uses: PyO3/maturin-action@db323e2cf5679b7feb8bcb561a36b27a0bc19e79 # v1
178
+ with:
179
+ command: sdist
180
+ args: --out dist
181
+ - name: Upload sdist
182
+ if: ${{ startsWith(github.ref, 'refs/tags/') || github.event_name == 'workflow_dispatch' }}
183
+ uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4
184
+ with:
185
+ name: wheels-sdist
186
+ path: dist
187
+
188
+ release:
189
+ name: Release
190
+ runs-on: ubuntu-latest
191
+ environment: pypi
192
+ if: ${{ startsWith(github.ref, 'refs/tags/') || github.event_name == 'workflow_dispatch' }}
193
+ needs: [linux, macos, sdist]
194
+ permissions:
195
+ # Use to sign the release artifacts
196
+ id-token: write
197
+ # Used to upload release artifacts
198
+ contents: write
199
+ # Used to generate artifact attestation
200
+ attestations: write
201
+ steps:
202
+ - uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4
203
+ - name: Generate artifact attestation
204
+ uses: actions/attest-build-provenance@96b4a1ef7235a096b17240c259729fdd70c83d45 # v2
205
+ with:
206
+ subject-path: "wheels-*/*"
207
+
208
+ - name: Collect distributions
209
+ run: |
210
+ mkdir -p dist
211
+ find wheels-* -type f \( -name '*.whl' -o -name '*.tar.gz' \) -exec cp {} dist/ \;
212
+
213
+ - name: Publish to PyPI
214
+ uses: pypa/gh-action-pypi-publish@release/v1
215
+ with:
216
+ packages-dir: dist
217
+
218
+ - name: Publish to GitHub Release
219
+ if: ${{ startsWith(github.ref, 'refs/tags/') }}
220
+ uses: softprops/action-gh-release@v2
221
+ with:
222
+ files: wheels-*/*
@@ -0,0 +1,75 @@
1
+ /target
2
+
3
+ # Byte-compiled / optimized / DLL files
4
+ __pycache__/
5
+ .pytest_cache/
6
+ *.py[cod]
7
+
8
+ # C extensions
9
+ *.so
10
+
11
+ # Distribution / packaging
12
+ .Python
13
+ .venv/
14
+ env/
15
+ bin/
16
+ build/
17
+ develop-eggs/
18
+ dist/
19
+ eggs/
20
+ lib/
21
+ lib64/
22
+ parts/
23
+ sdist/
24
+ var/
25
+ include/
26
+ man/
27
+ venv/
28
+ *.egg-info/
29
+ .installed.cfg
30
+ *.egg
31
+
32
+ # Installer logs
33
+ pip-log.txt
34
+ pip-delete-this-directory.txt
35
+ pip-selfcheck.json
36
+
37
+ # Unit test / coverage reports
38
+ htmlcov/
39
+ .tox/
40
+ .coverage
41
+ .cache
42
+ nosetests.xml
43
+ coverage.xml
44
+
45
+ # Translations
46
+ *.mo
47
+
48
+ # Mr Developer
49
+ .mr.developer.cfg
50
+ .project
51
+ .pydevproject
52
+
53
+ # Rope
54
+ .ropeproject
55
+
56
+ # Django stuff:
57
+ *.log
58
+ *.pot
59
+
60
+ .DS_Store
61
+
62
+ # Sphinx documentation
63
+ docs/_build/
64
+
65
+ # PyCharm
66
+ .idea/
67
+
68
+ # VSCode
69
+ .vscode/
70
+
71
+ # Pyenv
72
+ .python-version
73
+
74
+ # Avoid ignoring shadcn utils
75
+ !demo/harmony-demo/src/lib
@@ -0,0 +1,9 @@
1
+ # Harmony renderer
2
+
3
+ This project provides a structured way to create messages that get rendered into a set of tokens using our harmony prompt format.
4
+
5
+ The majority of the code is written in Rust inside `src/` and `src/py_module.rs` defines using pyo3 what functions are exposed to the python version of the library with a wrapper in `python/openai_harmony/__init__.py`.
6
+
7
+ You can build the Rust code along with the Python wrapper using `maturin develop --release`. This will also locally install the library in the venv so you can use it.
8
+
9
+ To test the library run `pytest`. That's the only way you can test it.