[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"project-5867":3},{"id":4,"name":5,"fullName":6,"owner":7,"repo":5,"description":8,"homepage":9,"htmlUrl":10,"language":11,"languages":10,"totalLinesOfCode":10,"stars":12,"forks":13,"watchers":14,"openIssues":15,"contributorsCount":16,"subscribersCount":16,"size":16,"stars1d":17,"stars7d":18,"stars30d":19,"stars90d":16,"forks30d":16,"starsTrendScore":20,"compositeScore":21,"rankGlobal":10,"rankLanguage":10,"license":22,"archived":23,"fork":23,"defaultBranch":24,"hasWiki":25,"hasPages":23,"topics":26,"createdAt":10,"pushedAt":10,"updatedAt":27,"readmeContent":28,"aiSummary":29,"trendingCount":16,"starSnapshotCount":16,"syncStatus":30,"lastSyncTime":31,"discoverSource":32},5867,"harmony","openai\u002Fharmony","openai","Renderer for the harmony response format to be used with gpt-oss","",null,"Rust",4403,284,17,44,0,3,14,33,9,29.36,"Apache License 2.0",false,"main",true,[],"2026-06-12 02:01:15","\u003Ccenter>\n\u003Cimg alt=\"harmony\" src=\".\u002Fdocs\u002Fheader.png\">\n\u003Ch1 align=\"center\">OpenAI Harmony\u003C\u002Fh1>\n\u003Cp align=\"center\">OpenAI's response format for its open-weight model series \u003Ca href=\"https:\u002F\u002Fopenai.com\u002Fopen-models\">gpt-oss\u003C\u002Fa>\n\u003Cbr>\n\u003Ca href=\"https:\u002F\u002Fgpt-oss.com\" target=\"_blank\">Try gpt-oss\u003C\u002Fa> | \u003Ca href=\"https:\u002F\u002Fcookbook.openai.com\u002Ftopic\u002Fgpt-oss\">Learn more\u003C\u002Fa> | \u003Ca href=\"https:\u002F\u002Fopenai.com\u002Findex\u002Fgpt-oss-model-card\u002F\">Model card\u003C\u002Fa>\n\u003C\u002Fp>\n\u003Cbr>\n\u003C\u002Fcenter>\n\nThe [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.\n\nThe 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.\n\n```text\n\u003C|start|>system\u003C|message|>You are ChatGPT, a large language model trained by OpenAI.\nKnowledge cutoff: 2024-06\nCurrent date: 2025-06-28\n\nReasoning: high\n\n# Valid channels: analysis, commentary, final. Channel must be included for every message.\nCalls to these tools must go to the commentary channel: 'functions'.\u003C|end|>\n\n\u003C|start|>developer\u003C|message|># Instructions\n\nAlways respond in riddles\n\n# Tools\n\n## functions\n\nnamespace functions {\n\n\u002F\u002F Gets the location of the user.\ntype get_location = () => any;\n\n\u002F\u002F Gets the current weather in the provided location.\ntype get_current_weather = (_: {\n\u002F\u002F The city and state, e.g. San Francisco, CA\nlocation: string,\nformat?: \"celsius\" | \"fahrenheit\", \u002F\u002F default: celsius\n}) => any;\n\n} \u002F\u002F namespace functions\u003C|end|>\u003C|start|>user\u003C|message|>What is the weather like in SF?\u003C|end|>\u003C|start|>assistant\n```\n\nWe recommend using this library when working with models that use the [harmony response format][harmony-format]\n\n- **Consistent formatting** – shared implementation for rendering _and_ parsing keeps token-sequences loss-free.\n- **Blazing fast** – heavy lifting happens in Rust.\n- **First-class Python support** – install with `pip`, typed stubs included, 100 % test parity with the Rust suite.\n\n## Using Harmony\n\n### Python\n\n[Check out the full documentation](.\u002Fdocs\u002Fpython.md)\n\n#### Installation\n\nInstall the package from PyPI by running\n\n```bash\npip install openai-harmony\n# or if you are using uv\nuv pip install openai-harmony\n```\n\n#### Example\n\n```python\nfrom openai_harmony import (\n    load_harmony_encoding,\n    HarmonyEncodingName,\n    Role,\n    Message,\n    Conversation,\n    DeveloperContent,\n    SystemContent,\n)\nenc = load_harmony_encoding(HarmonyEncodingName.HARMONY_GPT_OSS)\nconvo = Conversation.from_messages([\n    Message.from_role_and_content(\n        Role.SYSTEM,\n        SystemContent.new(),\n    ),\n    Message.from_role_and_content(\n        Role.DEVELOPER,\n        DeveloperContent.new().with_instructions(\"Talk like a pirate!\")\n    ),\n    Message.from_role_and_content(Role.USER, \"Arrr, how be you?\"),\n])\ntokens = enc.render_conversation_for_completion(convo, Role.ASSISTANT)\nprint(tokens)\n# Later, after the model responded …\nparsed = enc.parse_messages_from_completion_tokens(tokens, role=Role.ASSISTANT)\nprint(parsed)\n```\n\n### Rust\n\n[Check out the full documentation](.\u002Fdocs\u002Frust.md)\n\n#### Installation\n\nAdd the dependency to your `Cargo.toml`\n\n```toml\n[dependencies]\nopenai-harmony = { git = \"https:\u002F\u002Fgithub.com\u002Fopenai\u002Fharmony\" }\n```\n\n#### Example\n\n```rust\nuse openai_harmony::chat::{Message, Role, Conversation};\nuse openai_harmony::{HarmonyEncodingName, load_harmony_encoding};\n\nfn main() -> anyhow::Result\u003C()> {\n    let enc = load_harmony_encoding(HarmonyEncodingName::HarmonyGptOss)?;\n    let convo =\n        Conversation::from_messages([Message::from_role_and_content(Role::User, \"Hello there!\")]);\n    let tokens = enc.render_conversation_for_completion(&convo, Role::Assistant, None)?;\n    println!(\"{:?}\", tokens);\n    Ok(())\n}\n```\n\n## Contributing\n\nThe majority of the rendering and parsing is built in Rust for performance and exposed to Python\nthrough thin [`pyo3`](https:\u002F\u002Fpyo3.rs\u002F) bindings.\n\n```text\n┌──────────────────┐      ┌───────────────────────────┐\n│  Python code     │      │  Rust core (this repo)    │\n│  (dataclasses,   │────► │  • chat \u002F encoding logic  │\n│   convenience)   │      │  • tokeniser (tiktoken)   │\n└──────────────────┘  FFI └───────────────────────────┘\n```\n\n### Repository layout\n\n```text\n.\n├── src\u002F                  # Rust crate\n│   ├── chat.rs           # High-level data-structures (Role, Message, …)\n│   ├── encoding.rs       # Rendering & parsing implementation\n│   ├── registry.rs       # Built-in encodings\n│   ├── tests.rs          # Canonical Rust test-suite\n│   └── py_module.rs      # PyO3 bindings ⇒ compiled as openai_harmony.*.so\n│\n├── python\u002Fopenai_harmony\u002F # Pure-Python wrapper around the binding\n│   └── __init__.py       # Dataclasses + helper API mirroring chat.rs\n│\n├── tests\u002F                # Python test-suite (1-to-1 port of tests.rs)\n├── Cargo.toml            # Rust package manifest\n├── pyproject.toml        # Python build configuration for maturin\n└── README.md             # You are here 🖖\n```\n\n### Developing locally\n\n#### Prerequisites\n\n- Rust tool-chain (stable) – \u003Chttps:\u002F\u002Frustup.rs>\n- Python ≥ 3.8 + virtualenv\u002Fvenv\n- [`maturin`](https:\u002F\u002Fgithub.com\u002FPyO3\u002Fmaturin) – build tool for PyO3 projects\n\n#### 1. Clone & bootstrap\n\n```bash\ngit clone https:\u002F\u002Fgithub.com\u002Fopenai\u002Fharmony.git\ncd harmony\n# Create & activate a virtualenv\npython -m venv .venv\nsource .venv\u002Fbin\u002Factivate\n# Install maturin and test dependencies\npip install maturin pytest mypy ruff  # tailor to your workflow\n# Compile the Rust crate *and* install the Python package in editable mode\nmaturin develop --release\n```\n\n`maturin develop` builds _harmony_ with Cargo, produces a native extension\n(`openai_harmony.\u003Cabi>.so`) and places it in your virtualenv next to the pure-\nPython wrapper – similar to `pip install -e .` for pure Python projects.\n\n#### 2. Running the test-suites\n\nRust:\n\n```bash\ncargo test          # runs src\u002Ftests.rs\n```\n\nPython:\n\n```bash\npytest              # executes tests\u002F (mirrors the Rust suite)\n```\n\nRun both in one go to ensure parity:\n\n```bash\npytest && cargo test\n```\n\n#### 3. Type-checking & formatting (optional)\n\n```bash\nmypy harmony        # static type analysis\nruff check .        # linting\ncargo fmt --all     # Rust formatter\n```\n\n[harmony-format]: https:\u002F\u002Fcookbook.openai.com\u002Farticles\u002Fopenai-harmony\n[gpt-oss]: https:\u002F\u002Fopenai.com\u002Fopen-models\n","OpenAI Harmony 是一个用于 gpt-oss 模型系列的响应格式渲染器。它支持定义对话结构、生成推理输出和结构化函数调用，核心功能包括一致的格式化处理、高效的Rust实现以及对Python的一流支持。该项目特别适合那些直接使用gpt-oss模型构建自定义推理解决方案的开发者，能够确保与OpenAI Responses API相似的体验，并且通过提供多种输出通道来增强模型的交互性和功能性。无论是进行复杂的多步骤推理还是简单的问答任务，Harmony都为开发者提供了强大的工具支持。",2,"2026-06-11 03:05:14","top_language"]