feat(novita): add deepseek-v4-flash - #2098
Conversation
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
WalkthroughThis PR extends support for Novita's DeepSeek V4 proxy models by adding request body preprocessing that detects and handles empty reasoning fields similarly to DeepSeek, and adds the Novita provider configuration for deepseek-v4-flash with pricing and capability metadata. Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Pull request overview
Adds a Novita-routed mapping for DeepSeek V4 Flash and extends the existing “reasoning_content placeholder” workaround so Novita-proxied DeepSeek V4 tool-calling flows don’t get rejected by the upstream.
Changes:
- Add
novitaprovider mapping fordeepseek-v4-flash(asdeepseek/deepseek-v4-flash) with pricing and limits. - Extend the DeepSeek/Moonshot
reasoning_contentreinjection logic to also apply to Novita when routing DeepSeek V4 models.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| packages/models/src/models/deepseek.ts | Adds Novita provider mapping for deepseek-v4-flash with prices/context/max output. |
| packages/actions/src/prepare-request-body.ts | Applies the existing tool_calls + missing reasoning_content workaround to Novita-proxied DeepSeek V4 models. |
Comments suppressed due to low confidence (1)
packages/actions/src/prepare-request-body.ts:983
- Add unit coverage for the new Novita DeepSeek-V4 path: when usedProvider is "novita" and usedModel matches "deepseek/deepseek-v4*", assistant messages containing tool_calls should get a non-empty reasoning_content (single-space fallback) when missing. This logic is subtle and regression-prone, and prepare-request-body.ts already has a dedicated spec file where this can be asserted.
// non-empty placeholder there. Novita proxies DeepSeek V4 with the same
// upstream constraint, so apply the DeepSeek behavior there too.
const isNovitaDeepseekV4 =
usedProvider === "novita" && usedModel.startsWith("deepseek/deepseek-v4");
if (
usedProvider === "deepseek" ||
usedProvider === "moonshot" ||
isNovitaDeepseekV4
) {
const fallback =
usedProvider === "moonshot" || isNovitaDeepseekV4 ? " " : "";
processedMessages = processedMessages.map((m) => {
if (
m.role !== "assistant" ||
!m.tool_calls ||
!Array.isArray(m.tool_calls) ||
m.tool_calls.length === 0 ||
m.reasoning_content !== undefined
) {
return m;
}
const reasoning = m.reasoning ?? fallback;
return { ...m, reasoning_content: reasoning || fallback };
});
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| // non-empty placeholder there. Novita proxies DeepSeek V4 with the same | ||
| // upstream constraint, so apply the DeepSeek behavior there too. | ||
| const isNovitaDeepseekV4 = |
There was a problem hiding this comment.
The inline comment says to "apply the DeepSeek behavior" for Novita, but the code uses the Moonshot-style single-space placeholder (because empty string is treated as missing). Consider rewording to explicitly say you're applying the DeepSeek V4 tool_calls/reasoning_content workaround to Novita, and that Novita requires the non-empty placeholder.
Summary
deepseek-v4-flash(1.05M context, 393.2K max output, $0.14/$0.28 in/out, $0.028 cache read).reasoning_contentworkaround inprepare-request-body.tsto cover Novita-routeddeepseek/deepseek-v4-*models. Without this, Novita's upstream rejects follow-up assistant messages withtool_callsbut noreasoning_content. Uses a single-space placeholder (same trick as Moonshot k2.5/k2.6) since Novita treats an empty string as missing.Test plan
TEST_MODELS="novita/deepseek-v4-flash" pnpm test:e2e— 72 passed, 42 skipped, 0 failedTEST_MODELS="deepseek/deepseek-v4-flash,moonshot/kimi-k2.6" pnpm test:e2e apps/gateway/src/chat-toolcalls-result.e2e.ts— regression check, all greenpnpm test:unit— 970 passedpnpm build🤖 Generated with Claude Code
Summary by CodeRabbit
Release Notes