Repository navigation
feat(nah_chat): support reasoning_effort (chat completions + Responses API) - #29
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Adds first-class support for the OpenAI/DeepSeek reasoning effort parameter to
nah_chat, for both APIs:{base}/chat/completions)reasoning_effort(top level)ChatCompletionParamsBuilder::reasoning_effort("high"){base}/responses)reasoning: {"effort": ...}(nested)ResponsesParamsBuilder::reasoning_effort("high")Before this PR the values could only be passed as raw JSON (
insert(...)/reasoning(Value)), with no helper, no tests, no docs — and the two APIs use different wire spellings, which is easy to get wrong.Design notes
reasoning_efforttakes a plain&strand sends it verbatim (server-side validation): OpenAI reasoning models takenone/minimal/low/medium/high/xhigh/max, DeepSeek takeslow/high/max. No new public types.effortinto an existingreasoningobject, so it composes with the rawreasoning(Value)setter.reasoning(Value)itself keeps its whole-object semantics (documented + tested).insert(documented): DeepSeekthinking: {"type": "enabled"|"disabled"}, Qwen3/vLLMenable_thinking; in the Responses API DeepSeek usesreasoning.effort: "none"to disable thinking.nah_chatstays0.8.0,Cargo.toml/Cargo.lockuntouched. CHANGELOG entry is under## Unreleased. No new dependencies.Tests
test_chat_completion_params_builder_reasoning_effort— value set, passed through verbatim, absent by default.test_chat_completion_request_body_reasoning_effort— serialized body has top-levelreasoning_effortand no nestedreasoningobject.test_responses_request_body_reasoning_effort— serialized body hasreasoning.effortand no top-levelreasoning_effort.test_responses_reasoning_effort_merges_into_existing_object— merge semantics;reasoning(Value)still replaces the object.Verification
cargo fmt --checkclean,cargo build --workspaceok,cargo test --workspace→ 32 tests + 1 doctest pass, 0 failed.cargo clippy -p nah_chat --all-targets: no warnings from the new code (remaining warnings are pre-existing).nah_chat/examples/reasoning_effortrun withBASE_URL=http://127.0.0.1:8799): captured request bodies were/chat/completions -> reasoning_effort: "high"(noreasoning) and/responses -> reasoning: {"effort": "high"}(no top-levelreasoning_effort); the example processed the replayed reasoning/text/usage SSE and printedreasoning_tokens=Some(7)/Some(3).DEEPSEEK_API_KEYin the dev environment. To check:DEEPSEEK_API_KEY=... cargo run -p nah_chat --example reasoning_effort(swap inreasoning_effort("none")on the Responses call to confirm thinking is disabled, i.e.reasoning_tokens == 0).Docs / examples
nah_chat/README.md: new “Reasoning effort” section (per-API field table, examples, DeepSeek thinking-mode notes: effort mapping,temperature/frequency_penaltyignored,top_pclamped to >= 0.95).nah_chat/src/lib.rscrate docs feature bullet; CHANGELOG## Unreleased.README.md: how to set it from thenahCLI viamodel.extraParams(already works through the pass-through; no CLI code change).nah_chat/examples/reasoning_effort.rs;examples/responses.rsnow uses the typed-free string setter.