Repository navigation
W.1: OpenAI chat encode as one pure function returning plain data (on #38) - #39
Open
cunninghamcard-bit wants to merge 3 commits into
Open
cunninghamcard-bit wants to merge 3 commits into
cunninghamcard-bit wants to merge 3 commits into
Conversation
encode_chat(url, headers, model_id, &CallOptions, stream, parser) ->
EncodedChatRequest { url, headers, body, warnings } is the only place the
chat body is built; do_generate/do_stream resolve URL+headers
(OpenAIModel::encode_request), encode, then hand the result to the
execute_* helpers. New openai_factory_test compares encode output with all 7
recorded chat requests without a transport.
…at directly
openai/mod.rs: with_user_agent("openai", "4.0.83") (fixtures/aisdk/VERSIONS.json).
chat_encode_matches_recorded_requests_without_fetch derives the expected UA from
VERSIONS.json and asserts a provider-layer recorded UA starts with the encoded
one instead of comparing a literal. New unit test calls the pure encode_chat.
cunninghamcard-bit
added a commit
that referenced
this pull request
Oct 11, 2026
…quest, per #39); fix fetch.rs/azure line refs
cunninghamcard-bit
added a commit
that referenced
this pull request
Oct 11, 2026
cunninghamcard-bit
added a commit
that referenced
this pull request
Oct 11, 2026
…-agent Instead of overwriting the expected user-agent with the pinned value, each factory test checks what aimux sent against the recording: every recording contains the sent ai-sdk-provider-utils/<v> part, and a provider-layer recording (messages-stream-basic, generate-stream-basic, chat-stream-basic) starts with the sent ai-sdk-<pkg>/<v> part, like #39 does for openai. Mutation: setting the constant and VERSIONS.json together to a fake version (9.9.91/9.9.92/9.9.93) turns the three stream tests red.
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.1 (PHASES 1W; A9 W2). Stacked on #38 (W.0,
exp/w0-wire-docs@ f9e40b0, which sits on #37 and E.6). The PR base is that branch.Change (
aimux-providers/src/openai/model.rs)EncodedChatRequest { url, headers, body, warnings }. It holds only plain data: no closures and no transport. It is re-exported asaimux_providers::openai::EncodedChatRequest.encode_chat(url, headers, model_id, &CallOptions, stream, parser). It reusesconvert.rs:1094build_request_body_with_chat_options, and is now its only call site inmodel.rs.rg -n 'build_request_body_with_chat_options' aimux-providers/src/openai/model.rsfinds one line,:211, insideencode_chat.OpenAIModel::encode_request(&CallOptions, stream)(#[doc(hidden)] pub). It resolves the configured URL and headers (the credential included), then callsencode_chat.do_generate/do_streamnow callencode_requestand build theHttpRequestfrom the encoded url and headers.execute_generate/execute_streamreceive theEncodedChatRequestand no longer build the body themselves.Acceptance
New test
openai_factory_test::chat_encode_matches_recorded_requests_without_fetch:chat-custom-nameandchat-headers-merge.request, and asserts the mock transport saw zero requests:urlmust be equal.bodymust be equal.content-typeis added later by the helper.ai-sdk-openai/4.0.80; the helper appendsai-sdk-provider-utils/5.0.51when sending.Fixture and cassette diff: zero.
Results (local linux x64)
Python was not run (no venv).