Files
new-api/relay/channel/ali/text.go
T
CaIon 14a9acd368 feat(custom): CNY native billing, daily check-in button, subscription plans page, usage docs and promo banner
Based on QuantumNous/new-api v1.0.0-rc.36 (shallow history squashed).

- CNY quota display mode: RMB-denominated top-up and crediting across Epay/Waffo channels
- New CheckinButton in both authenticated and public headers (Turnstile supported)
- New /subscribe page with public plan snapshot, Alipay/balance payment, auto group upgrade/reset
- New /docs 12-section beginner guide with anchor navigation
- New home PromoBanner linking to /docs; i18n synced (en/zh/zh-TW/fr/ja/ru/vi)
- README: document custom features, live demo https://ai.88531.cn
2026-09-23 16:28:52 +08:00

37 lines
1.1 KiB
Go

package ali
import (
"github.com/QuantumNous/new-api/relaykit/dto"
"github.com/samber/lo"
)
// https://help.aliyun.com/document_detail/613695.html?spm=a2c4g.2399480.0.0.1adb778fAdzP9w#341800c0f8w0r
const EnableSearchModelSuffix = "-internet"
func requestOpenAI2Ali(request dto.GeneralOpenAIRequest, upstreamModelName string) *dto.GeneralOpenAIRequest {
modelName := upstreamModelName
if modelName == "" {
modelName = request.Model
}
if !dto.IsQwenThinkingBudgetModel(modelName) {
request.ThinkingBudget = nil
}
// DashScope rejects top_p at the 0 and 1 boundaries, so an explicit value is
// clamped into the open interval. The clamp stays at two decimals because
// some models on the platform reject a third decimal with
// "top_p参数非法:限制小数点[2]位".
//
// A request that omits top_p is left untouched: injecting a value would
// silently replace the model's own default with near-greedy decoding.
if request.TopP != nil {
if *request.TopP >= 1 {
request.TopP = lo.ToPtr(0.99)
} else if *request.TopP <= 0 {
request.TopP = lo.ToPtr(0.01)
}
}
return &request
}