Repository navigation
refactor: give openai its own completion model - #391
Merged
Merged
Conversation
OpenAICompletionModel was an alias of the OpenAI-compatible completion model, which carried a Native branch with the OpenAI config, error handler and stream errors, so OpenAI and the compatible layer formed a cycle. OpenAI now has its own model, as @ai-sdk/openai does (openai-completion-language-model.ts); the compatible model drops the native branch (RFC-0046 §3.3, R2). Requests and results are unchanged. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0116HPMoqaLfFr1TyqDq1hrW
eric8810
approved these changes
Oct 28, 2026
eric8810
left a comment
Contributor
There was a problem hiding this comment.
OpenAI native completion 分支是忠实搬移,compatible 路径未变,factory/default provider/exports 都接上了,OpenAI→compatible completion cycle 消失。Approve;建议补一条 CHANGELOG Breaking 记录 alias→distinct struct。
This was referenced Oct 28, 2026
cunninghamcard-bit
pushed a commit
that referenced
this pull request
Oct 28, 2026
#391 replaced the alias of the compatible completion model with a struct of its own; record that as a Breaking change, as review on #391 suggested. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0116HPMoqaLfFr1TyqDq1hrW
This was referenced Oct 28, 2026
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.
Before:
OpenAICompletionModel是OpenAICompatibleCompletionModel的类型别名。兼容层的 completion 模型为此带一个CompletionConfig::Native(OpenAIModelConfig)分支,里面用 OpenAI 的配置、openai_failed_response_handler和openai_stream_error;OpenAI 又把 completion 交给兼容层,两个目录互相引用(RFC-0046 §3.3 的 OpenAI ↔ 兼容层环)。After:OpenAI 照上游
@ai-sdk/openai有自己的 completion 模型(上游src/completion/本来就是 openai 包自己的),写在layout.toml早已指定的openai/completion/completion_language_model.rs。兼容层的 completion 模型去掉 Native 分支,只剩兼容层自己的逻辑。请求体、结果、流事件都不变。这是 RFC-0046 R2(拆环)的第三个 PR,跟踪在 #328;前两个是 #389、#390。
一、体系现状(概览)
上游:两个包各有一份 completion 模型,互不引用。
aimux(本 PR 之前):
二、本 PR 改动(细节)
兼容层里还剩一处引用 OpenAI:
chat/convert_to_chat_messages.rs用crate::openai::convert::tool_result_to_content,#386 把它移到 provider-utils,合入后这个环就完全断开。测试
cargo test(aimux-providers lib)openai-completion-language-model.test.ts移植)CompletionConfig的匹配体积
源码多出约 300 行,是上游两个包各有一份 completion 的代价(提示词转换约 50 行两边相同)。completion 是遗留接口,两份分开后各自跟上游走。
公开 API 与行为
aimux_providers::openai::OpenAICompletionModel名字不变,从类型别名变成独立结构体,同样实现LanguageModel。只有把它当成OpenAICompatibleCompletionModel用的代码会受影响;仓库里(各 crate 和各语言绑定)没有这样的用法。检查
cargo +1.99 fmt --check、cargo +1.99 clippy --workspace --all-targets --all-features -D warnings、cargo doc、scripts/check_provider_boundaries.sh、全量测试,均通过。🤖 Generated with Claude Code
https://claude.ai/code/session_0116HPMoqaLfFr1TyqDq1hrW