Repository navigation
W.2: OpenAI chat decode module (finish + usage) shared by generate and stream (on #39; merges #29, #33) - #40
Open
cunninghamcard-bit wants to merge 8 commits into
Conversation
Matches AI SDK map-openai-finish-reason.ts:13-15; raw stays "function_call". Unit test added.
Matches AI SDK @ai-sdk/openai@4.0.83 convert-openai-chat-usage.ts:28. Drops UsageResponse.cached_tokens (top-level value stays in usage.raw). Moonshot keeps its behaviour via compat ConvertUsage::MoonshotAI.
…o exp/w2-openai-chat-decode
…ns' into exp/w2-openai-chat-decode
openai/decode.rs owns parse_finish_reason (moved from convert.rs, still re-exported there), finish_reason(Option<&str>) (None -> Other, used by both paths incl. the stream default) and convert_usage (moved from model.rs, D28 nested-only kept). A.1 and A.5 unit tests move with them.
…nvert re-export convert.rs re-export of decode::parse_finish_reason had no users workspace-wide (providers, ffi, bindings, tools).
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.
Unit W.2 (PHASES 1W; A9 W3). Branch cut from W.1 (#39, c4e8024); PR base is
exp/w1-openai-chat-encode.The branch also contains two merge commits (no force-push):
origin/exp/a1-function-call-finish(A.1: OpenAI chat finish_reason function_call -> ToolCalls (phase 1A) #29, A.1)origin/exp/a5-openai-nested-cached-tokens(A.5 (D28): native OpenAI chat cacheRead reads only nested cached_tokens #33, A.5, D28)Both merged without conflicts.
Where the non-streaming finish mapping was
aimux-providers/src/openai/model.rs:331-338(after the merges):It passed
parse_finish_reasonas a function (.map(parse_finish_reason)), so a grep forparse_finish_reason(never found it. The "no finish reason givesOther" default was also written out twice: once there, and once in the stream path's finish (:748-751).Change
New
aimux-providers/src/openai/decode.rs, private module:parse_finish_reason: moved fromconvert.rs, including A.1'sfunction_call→ ToolCalls.convert.rskeepspub use super::decode::parse_finish_reason;so the publicopenai::convert::parse_finish_reasonpath still works.finish_reason(Option<&str>):NonegivesOtherwith no raw value.convert_usage: moved frommodel.rs, keeping D28 (cacheRead from nestedcached_tokensonly).Call sites in
model.rs:finish_reason:265:628(chunk),:676(default)convert_usage:268:523rg -n 'fn parse_finish_reason\|fn finish_reason\|fn convert_usage' aimux-providers/src/openai/finds each function defined exactly once, all indecode.rs.Tests
function_call_finish_reason_is_tool_callsand A.5's three cached-token tests moved with the code and pass asopenai::decode::tests::*.missing_finish_reason_is_other.openai_upstream_e2e_test), factory (openai_factory_test, including W.1's encode test) and output round-trip tests all pass unchanged.Results (local linux x64)
Python was not run (no venv).