Skip to content

fix: normalize kimi k2.6 temperature - #5390

Merged
seefs001 merged 1 commit into
QuantumNous:mainfrom
bensonfx:normalize_kimi_temperature
Jun 10, 2026
Merged

fix: normalize kimi k2.6 temperature#5390
seefs001 merged 1 commit into
QuantumNous:mainfrom
bensonfx:normalize_kimi_temperature

Conversation

@bensonfx

@bensonfx bensonfx commented Jun 9, 2026

Copy link
Copy Markdown
Contributor

📝 变更描述 / Description

修复 Moonshot 渠道下 kimi-k2.6 请求的 temperature 处理逻辑。

kimi-k2.6 上游只接受 temperature = 1.0。本次变更在 Moonshot OpenAI 兼容请求转换阶段,根据最终上游模型名识别 kimi-k2.6,当请求显式传入非 1.0 的 temperature
时自动归一化为 1.0,避免上游返回参数错误。

未显式传入 temperature 的请求保持省略状态,其他 Moonshot 模型不受影响。

🚀 变更类型 / Type of change

  • 🐛 Bug 修复 (Bug fix) - 请关联对应 Issue,避免将设计取舍、理解偏差或预期不一致直接归类为 bug
  • ✨ 新功能 (New feature) - 重大特性建议先通过 Issue 沟通
  • ⚡ 性能优化 / 重构 (Refactor)
  • 📝 文档更新 (Documentation)

🔗 关联任务 / Related Issue

✅ 提交前检查项 / Checklist

  • 人工确认: 我已亲自整理并撰写此描述,没有直接粘贴未经处理的 AI 输出。
  • 非重复提交: 我已搜索现有的 IssuesPRs,确认不是重复提
    交。
  • Bug fix 说明: 若此 PR 标记为 Bug fix,我已提交或关联对应 Issue,且不会将设计取舍、预期不一致或理解偏差直接归类为 bug。
  • 变更理解: 我已理解这些更改的工作原理及可能影响。
  • 范围聚焦: 本 PR 未包含任何与当前任务无关的代码改动。
  • 本地验证: 已在本地运行并通过测试或手动验证,维护者可以据此复核结果。
  • 安全合规: 代码中无敏感凭据,且符合项目代码规范。

📸 运行证明 / Proof of Work

go test -count=1 ./relay/channel/moonshot

ok  	github.com/QuantumNous/new-api/relay/channel/moonshot	0.009s

<!-- This is an auto-generated comment: release notes by coderabbit.ai -->

## Summary by CodeRabbit

## Release Notes

* **Bug Fixes**
* Corrected temperature parameter handling for the kimi-k2.6 model to ensure consistent and compatible behavior.

* **Tests**
* Added unit tests validating temperature parameter handling across Moonshot models.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->

@coderabbitai

coderabbitai Bot commented Jun 9, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 95112a89-6ea5-4d21-a1b4-767c6b7cc680

📥 Commits

Reviewing files that changed from the base of the PR and between d2576dd and 6f543aa.

📒 Files selected for processing (2)
  • relay/channel/moonshot/adaptor.go
  • relay/channel/moonshot/adaptor_test.go

Walkthrough

The Moonshot adapter adds temperature normalization logic to enforce the kimi-k2.6 model's requirement that temperature must be exactly 1.0, converting any provided temperature value or omitting it when absent, while preserving temperature for other Moonshot models.

Changes

Moonshot adapter temperature constraint handling

Layer / File(s) Summary
Temperature constraint implementation
relay/channel/moonshot/adaptor.go
Added strings and common package imports. Enhanced ConvertOpenAIRequest to detect the kimi-k2.6 upstream model and force its temperature to exactly 1.0 using helper functions for model name resolution and one-only constraint detection.
Temperature handling unit tests
relay/channel/moonshot/adaptor_test.go
Added three unit tests validating that temperature is normalized to 1.0 for kimi-k2.6 when provided, preserved as omitted when not provided, and left unchanged for other models like kimi-k2.5.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Poem

🐰 A rabbit hops through adaptor code,
where Kimi's temperature must always load,
at one-point-zero, locked and tight—
no more bad requests in the night! 🌙✨

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely identifies the main change: fixing temperature normalization for the kimi k2.6 model in the Moonshot adapter.
Linked Issues check ✅ Passed The PR successfully implements the core requirement from issue #5372: the Moonshot adapter now normalizes temperature to 1.0 for kimi-k2.6 while preserving omitted temperatures and not affecting other models.
Out of Scope Changes check ✅ Passed All changes are directly scoped to the Moonshot adapter's temperature handling for kimi-k2.6, with supporting test coverage; no unrelated modifications detected.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@seefs001
seefs001 merged commit 867d8ac into QuantumNous:main Jun 10, 2026
2 checks passed
endercat-alu pushed a commit to endercat-alu/new-api that referenced this pull request Jun 10, 2026
@bensonfx
bensonfx deleted the normalize_kimi_temperature branch June 11, 2026 06:49
tongkaiteng pushed a commit to tongkaiteng/new-api that referenced this pull request Jun 12, 2026
YeMao11 pushed a commit to YeMao11/new-api that referenced this pull request Jun 16, 2026
Upstream changes (50+ commits, v1.0.0-rc.11):
- data-table perf: row selection memo, column pinning, badge display
- Fixes: channel test dialog (QuantumNous#5517), CC Switch model selector (QuantumNous#5515),
  API key form options (QuantumNous#5512), cell overflow (QuantumNous#5510), kimi k2.6 temp (QuantumNous#5390),
  Anthropic-compatible GLM chunked encoding (QuantumNous#5307), streaming image relay (QuantumNous#4608)
- Feat: audit auth method tracking (QuantumNous#5462), channel affinity clear toggle (QuantumNous#5306),
  relay idle timeout config (QuantumNous#5309), 6-decimal pricing precision (QuantumNous#5332)
- Classic frontend: Rsbuild support, Semi React 19 adapter
- Shared dialog wrapper, JSON code editor, debounce channel search

Conflict resolved: web/bun.lock (accepted upstream, will regenerate)

Co-Authored-By: Claude <noreply@anthropic.com>
YeMao11 pushed a commit to YeMao11/new-api that referenced this pull request Jun 16, 2026
Merge upstream v1.0.0-rc.11 (50+ commits):
- data-table perf: row selection memo, column pinning, badge display
- Fixes: channel test dialog (QuantumNous#5517), CC Switch (QuantumNous#5515), API key (QuantumNous#5512),
  kimi k2.6 temp (QuantumNous#5390), GLM chunked encoding (QuantumNous#5307), streaming image (QuantumNous#4608)
- Feat: audit auth tracking (QuantumNous#5462), channel affinity toggle (QuantumNous#5306),
  relay idle timeout (QuantumNous#5309), 6-decimal pricing (QuantumNous#5332)
- Shared dialog wrapper, JSON code editor, classic Rsbuild support

SEO optimization:
- robots.txt: 10 AI crawler blocks + 22 path disallows + crawl-delay
- sitemap.xml: 7 public URLs with 6-language hreflang annotations
- index.html: hreflang tags, og:locale:alternate, og:image, canonical,
  5 structured data types (Organization, SoftwareApplication, FAQPage,
  WebSite, SearchAction), expanded keywords (gateway, agent router,
  aggregation, orchestration)
- i18n/config.ts: sync <html lang> with active language for SEO

Co-Authored-By: Claude <noreply@anthropic.com>
jjcc123312 added a commit to SolveaCX/new-api that referenced this pull request Jun 17, 2026
sync: cherry-pick low-risk upstream fixes (kimi temp QuantumNous#5390, deleted-user filter QuantumNous#5464)
QQhuxuhui added a commit to QQhuxuhui/new-api that referenced this pull request Jun 30, 2026
dev 与 upstream 无共同祖先、不能 cherry-pick,按文件手工 port:
- 502858d fix(QuantumNous#5543): tool 调用 arguments 为空时保留 tool_use 块
- 45cc95a fix(gemini): ToolConfig 加 IncludeServerSideToolInvocations 字段
- 8ca1033 fix: ReasoningContent/Reasoning 改 *string,修复空思考内容转发被静默丢弃
  (并适配 dev 自研 openaicompat/responses_to_chat.go 的 *string 赋值)
- 867d8ac fix(QuantumNous#5390): kimi-k2.6 温度归一化(import 冲突已解,去掉未用的 channelconstant)
- ff06067 fix(QuantumNous#5095): 移除 fcIdx -1 偏移,修复并发工具调用撞键

go build ./... 与 go vet 均通过。

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
QQhuxuhui added a commit to QQhuxuhui/new-api that referenced this pull request Jun 30, 2026
包含:QuantumNous#5543 tool_use / gemini 字段 / ReasoningContent *string / QuantumNous#5390 kimi 温度 /
QuantumNous#5095 并发工具撞键 / aa56667 A 防上游 request-id 覆盖
ruanhangjian pushed a commit to ruanhangjian/new-api that referenced this pull request Jul 11, 2026
noah-wung pushed a commit to noah-wung/new-api that referenced this pull request Jul 17, 2026
zhaodechao2008 pushed a commit to zhaodechao2008/new-api that referenced this pull request Jul 27, 2026
330079598 pushed a commit to 330079598/new-api that referenced this pull request Aug 19, 2026
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.

Bug: Moonshot adapter fails with 400 error for kimi-k2.6 due to unsupported temperature value

2 participants