From 779cd8386216c4c0bafc78a782d44248a41110be Mon Sep 17 00:00:00 2001 From: Jin Hai Date: Sat, 9 May 2026 20:05:57 +0800 Subject: [PATCH] Go: fix Baidu rerank issue (#14742) ### What problem does this PR solve? top_n is missing ### Type of change - [x] Bug Fix (non-breaking change which fixes an issue) Signed-off-by: Jin Hai --- internal/entity/models/baidu.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/internal/entity/models/baidu.go b/internal/entity/models/baidu.go index 4f94950203..ad24ced9b4 100644 --- a/internal/entity/models/baidu.go +++ b/internal/entity/models/baidu.go @@ -520,10 +520,16 @@ func (b *BaiduModel) Rerank(modelName *string, query string, documents []string, url := fmt.Sprintf("%s/%s", strings.TrimSuffix(b.BaseURL[region], "/"), b.URLSuffix.Rerank) + var topN = rerankConfig.TopN + if rerankConfig.TopN == 0 { + topN = len(documents) + } + reqBody := map[string]interface{}{ "model": *modelName, "query": query, "documents": documents, + "top_n": topN, } jsonData, err := json.Marshal(reqBody)