mirror of
https://github.com/alibaba/higress.git
synced 2026-06-09 20:57:32 +08:00
Fix error due to incompatible top_p range (#1250)
This commit is contained in:
@@ -101,6 +101,18 @@ func (m *qwenProvider) OnRequestBody(ctx wrapper.HttpContext, apiName ApiName, b
|
|||||||
log.Errorf("Replace model error: %v", err)
|
log.Errorf("Replace model error: %v", err)
|
||||||
return types.ActionContinue, err
|
return types.ActionContinue, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO: Temporary fix to clamp top_p value to the range [qwenTopPMin, qwenTopPMax].
|
||||||
|
if topPValue := gjson.GetBytes(body, "top_p"); topPValue.Exists() {
|
||||||
|
rawTopP := topPValue.Float()
|
||||||
|
scaledTopP := math.Max(qwenTopPMin, math.Min(rawTopP, qwenTopPMax))
|
||||||
|
newBody, err = sjson.SetBytes(newBody, "top_p", scaledTopP)
|
||||||
|
if err != nil {
|
||||||
|
log.Errorf("Failed to replace top_p: %v", err)
|
||||||
|
return types.ActionContinue, err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
err = proxywasm.ReplaceHttpRequestBody(newBody)
|
err = proxywasm.ReplaceHttpRequestBody(newBody)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Errorf("Replace request body error: %v", err)
|
log.Errorf("Replace request body error: %v", err)
|
||||||
|
|||||||
Reference in New Issue
Block a user