Skip to content

refactor: move the DeepSeek files to the upstream layout - #300

Merged
eric8810 merged 12 commits into
masterfrom
refactor/move-the-deepseek-files-to-the-upstream-layout
Oct 27, 2026
Merged

eric8810 merged 12 commits into
masterfrom
refactor/move-the-deepseek-files-to-the-upstream-layout

Conversation

@cunninghamcard-bit

@cunninghamcard-bit cunninghamcard-bit commented Oct 20, 2026 •

Copy link
Copy Markdown
Contributor

Summary

按 RFC-0046 §4.2、§5(#294)把 DeepSeek 的文件按 @ai-sdk/deepseek 逐个对应,做法和 Mistral(#297)、Cohere(#298)、Hugging Face(#304)相同。叠在 #299(DeepSeek 测试迁移)上。只挪不改:没有改任何函数体和断言,测试数前后都是 257,测试函数名和 describe 路径完全一致。

测试位置按 10-20 定的新布局:DeepSeek 的测试全部在 src/deepseek/tests/,一个上游测试文件对应一个同名 Rust 文件,不再有 foo/tests.rs 和 tests/it/。

已经测试分支 26e6e755 合上 master b69137eb,冲突按 master 的改动搬到新位置解决(错误改成 RFC-0047 的构造函数和结构体变体,落到 chat/chat_language_model_options.rs、provider.rs 和 tests/chat/chat_language_model.rs);测试数前后仍相等(DeepSeek 119 个,lib 118 个加留在 tests/ 的 1 个,名字多重集相同)。

一、体系概览:一次 DeepSeek 调用经过哪些文件(#299 head f7d20a2b)

create_deepseek                                     deepseek/mod.rs:86            上游 src/deepseek-provider.ts
 └ DeepSeekProvider::chat                           deepseek/mod.rs:146
   └ DeepSeekChatLanguageModel::do_generate / do_stream   deepseek/model.rs:364 / :481   上游 src/chat/deepseek-chat-language-model.ts
     └ request_body                                 deepseek/model.rs:154         上游 getArgs
       ├ parse_chat_options                         deepseek/options.rs:125       上游 src/chat/deepseek-chat-language-model-options.ts
       ├ convert_to_deepseek_chat_messages          deepseek/convert.rs:129       上游 src/chat/convert-to-deepseek-chat-messages.ts
       │ └ parse_file_part_options                  deepseek/options.rs:188       上游 src/chat/deepseek-file-part-options.ts
       ├ is_deepseek_v4_model                       deepseek/is_v4_model.rs:6     上游 src/chat/is-deepseek-v4-model.ts
       └ prepare_tools                              deepseek/prepare_tools.rs:25  上游 src/chat/deepseek-prepare-tools.ts
     ├ ChatResponse / ChatChunk、错误处理            deepseek/types.rs:14          上游 src/chat/deepseek-chat-api-types.ts
     ├ convert_deepseek_usage                       deepseek/usage.rs:16          上游 src/chat/convert-to-deepseek-usage.ts
     └ map_deepseek_finish_reason                   deepseek/finish_reason.rs:6   上游 src/chat/map-deepseek-finish-reason.ts

DeepSeek 原来就基本一个上游文件一个 Rust 文件,差别在三处:上游的模型代码都在 src/chat/ 子目录,aimux 平铺;options.rs 装了两个上游文件;mod.rs 既是 index.ts 又是 provider。测试:#299 的 23 个在 src/deepseek/tests/chat/,另有 2 个独立测试程序 tests/deepseek_chat_test.rs(95 个,wiremock,含修复 PR #309 加的 2 个)和 tests/deepseek_test.rs(cassette 回放 4 个)。

二、本 PR 的改动(细节)

1. 源文件:照上游建 chat/ 子目录,去掉和目录重复的厂商前缀

create_deepseek                                     deepseek/provider.rs:68       deepseek-provider.ts
 └ DeepSeekProvider::chat                           deepseek/provider.rs:128
   └ DeepSeekChatLanguageModel::do_generate / do_stream   deepseek/chat/chat_language_model.rs:366 / :483
     └ request_body                                 deepseek/chat/chat_language_model.rs:156
       ├ parse_chat_options                         deepseek/chat/chat_language_model_options.rs:114
       ├ convert_to_deepseek_chat_messages          deepseek/chat/convert_to_chat_messages.rs:130
       │ └ parse_file_part_options                  deepseek/chat/file_part_options.rs:27   从 options.rs 拆出
       ├ is_deepseek_v4_model                       deepseek/chat/is_v4_model.rs:6
       └ prepare_tools                              deepseek/chat/prepare_tools.rs:25
     ├ ChatResponse / ChatChunk、错误处理            deepseek/chat/chat_api_types.rs:14
     ├ convert_deepseek_usage                       deepseek/chat/convert_to_usage.rs:16
     └ map_deepseek_finish_reason                   deepseek/chat/map_finish_reason.rs:6
deepseek/mod.rs        只剩 mod 声明、pub use 和 #[cfg(test)] mod tests;     index.ts
deepseek/chat/mod.rs   只有 mod 声明和 pub use     (上游 chat/ 没有 index.ts)

file_part_options.rs 用的两个解析小函数 parse_namespace、invalid 留在 chat_language_model_options.rs,改成 pub(super)。测试直接调用的四个模块(convert_to_chat_messages、convert_to_usage、is_v4_model、prepare_tools)在 chat/mod.rs 里是 pub(super) mod,让 deepseek::tests 看得到。layout.toml 的 rust 字段同步改成新文件名。

2. 测试:全部在 src/deepseek/tests/chat/,和上游 src/chat/*.test.ts 同名

#299 的 6 个文件              use 路径跟着改名后的源文件(crate::deepseek::chat::…)
tests/deepseek_chat_test.rs(95 个)按 describe 并进同名文件:
  mod deep_seek_chat_language_model      → chat_language_model.rs   和 #299 的快照用例合并
  文件末尾 20 个 aimux 自己的用例         → chat_language_model.rs 末尾
  mod convert_to_deep_seek_chat_messages → convert_to_chat_messages.rs   和 #299 直接调函数的用例合并
  mod prepare_tools                      → prepare_tools.rs
  原文件顶部的 wiremock 帮手函数          → support.rs(pub(super),三个文件 use super::support::*)
tests/deepseek_test.rs               cassette 回放,留在 crate 的 tests/,只改了文件头注释里的旧文件名

合并 chat_language_model.rs 时,#299 文件里有 5 个帮手函数和 support.rs 重名(options、weather_tool、tool_options、json_options、stream_parts),给它们加了 fixture_ 前缀;测试函数本身不变。

Type of change

  • Bug fix (non-breaking)
  • New feature (non-breaking)
  • Breaking change
  • New provider
  • New / updated binding
  • Docs / RFC
  • Refactor(文件搬移)

Checklist

  • cargo fmt --all -- --check passes
  • cargo +1.99 clippy -p aimux-providers --lib --tests -- -D warnings、cargo doc -D warnings pass
  • DeepSeek 的 118 个 lib 测试、deepseek_test 4 个、non_object_tool_input_test 全过
  • 测试数前后相等:test: port the upstream DeepSeek tests #299 上 lib 158 + deepseek_chat 95 + deepseek 4 = 257,本 PR lib 253 + deepseek 4 = 257;去掉文件层前缀后,每个测试的完整模块路径逐个相同
  • scripts/check_provider_boundaries.sh passes
  • Commit messages follow Conventional Commits

Notes for reviewers

共享进程状态:测试原来各自是单独的测试程序,现在并进 lib 的同一个测试程序。本家的测试不改环境变量,不用全局计数器和固定临时路径,搬进来不受别家影响(RFC-0046 §5)。

https://claude.ai/code/session_0116HPMoqaLfFr1TyqDq1hrW


Generated by Claude Code

One Rust file per @ai-sdk/deepseek source file (RFC-0046 §4.2), with
upstream's chat/ directory: model.rs becomes chat/chat_language_model.rs,
convert.rs chat/convert_to_chat_messages.rs, usage.rs
chat/convert_to_usage.rs, types.rs chat/chat_api_types.rs, finish_reason.rs
chat/map_finish_reason.rs, and options.rs splits into
chat/chat_language_model_options.rs and chat/file_part_options.rs. mod.rs
keeps only the module list (index.ts); the provider is in provider.rs.

The tests follow: tests/deepseek_chat_test.rs splits by upstream test file
into tests/it/deepseek/chat/ (chat_language_model.rs, merged with the
snapshot ports, convert_to_chat_messages.rs and prepare_tools.rs) over a
shared wiremock harness in support.rs; tests/deepseek_test.rs moves to
tests/it/deepseek/replay.rs. Move only: the test count (255), the test
function names and their module paths are unchanged.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0116HPMoqaLfFr1TyqDq1hrW
The test PR now keeps every DeepSeek test in src/deepseek/tests/
(RFC-0046 §5). The renamed source files stay as before under
src/deepseek/chat/; the test modules' use paths follow them, and the
four chat modules the tests call (convert_to_chat_messages,
convert_to_usage, is_v4_model, prepare_tools) are pub(super) in chat/.

tests/deepseek_chat_test.rs joins src/deepseek/tests/chat/ by describe
block: chat_language_model.rs, convert_to_chat_messages.rs and
prepare_tools.rs, its wiremock helpers in support.rs. tests/it/ is gone;
the cassette replay stays in tests/deepseek_test.rs. Move only: the 255
tests keep their names and describe paths.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0116HPMoqaLfFr1TyqDq1hrW
The test branch now stacks on fix PR #309, which adds two aimux-own
tests at the end of tests/deepseek_chat_test.rs. That file is already
merged into src/deepseek/tests/chat/, so the two tests land at the end
of chat_language_model.rs with the other aimux-own cases.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0116HPMoqaLfFr1TyqDq1hrW
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0116HPMoqaLfFr1TyqDq1hrW
@cunninghamcard-bit
cunninghamcard-bit marked this pull request as ready for review October 24, 2026 11:34

@eric8810 eric8810 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

DeepSeek layout refactor:move-only,测试数 1740→1740,公开 API 不变。Approve。

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0116HPMoqaLfFr1TyqDq1hrW

Copy link
Copy Markdown
Contributor Author

批准之后推了一个只改注释的提交 e3e3e5d3:tests/non_object_tool_input_test.rs 第 10 行改成和 #302 相同的一行(Groq 和 DeepSeek 都指向搬移后的文件),这样两个 PR 先后合进 master 时这一行不冲突。没有别的改动。


Generated by Claude Code

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0116HPMoqaLfFr1TyqDq1hrW
… is here

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0116HPMoqaLfFr1TyqDq1hrW

Copy link
Copy Markdown
Contributor Author

按 eric 在 #302 的意见,tests/non_object_tool_input_test.rs 第 10 行只改各自厂商的部分:这里 d6f0f78f 把 Groq 留作本分支实际存在的 groq/convert.rs:88,DeepSeek 指向搬移后的 deepseek/chat/convert_to_chat_messages.rs:285。只改注释。#300 和 #302 后合的那个在这一行会有一处冲突,我合 master 时解决。


Generated by Claude Code

…tests' into refactor/move-the-deepseek-files-to-the-upstream-layout

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0116HPMoqaLfFr1TyqDq1hrW
…tests' into refactor/move-the-deepseek-files-to-the-upstream-layout

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0116HPMoqaLfFr1TyqDq1hrW
…tests' into refactor/move-the-deepseek-files-to-the-upstream-layout

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0116HPMoqaLfFr1TyqDq1hrW
…tests' into refactor/move-the-deepseek-files-to-the-upstream-layout

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0116HPMoqaLfFr1TyqDq1hrW
…tests' into refactor/move-the-deepseek-files-to-the-upstream-layout

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0116HPMoqaLfFr1TyqDq1hrW

@eric8810 eric8810 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verified the post-approval commits on this head: only additive tests/docs or tightened boundary checks; no weakening or behavior regression. Re-approving the current head.

@eric8810
eric8810 changed the base branch from test/port-the-upstream-deepseek-tests to master October 27, 2026 01:21
@eric8810
eric8810 merged commit 2b9f094 into master Oct 27, 2026
16 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants