mirror of
				https://github.com/linux-do/new-api.git
				synced 2025-11-04 13:23:42 +08:00 
			
		
		
		
	fix: fix rerank
This commit is contained in:
		@@ -4,6 +4,7 @@ import (
 | 
			
		||||
	"fmt"
 | 
			
		||||
	"github.com/gin-gonic/gin"
 | 
			
		||||
	"io"
 | 
			
		||||
	"log"
 | 
			
		||||
	"net/http"
 | 
			
		||||
	"one-api/dto"
 | 
			
		||||
	"one-api/relay/channel"
 | 
			
		||||
@@ -39,6 +40,7 @@ func (a *Adaptor) ConvertRequest(c *gin.Context, relayMode int, request *dto.Gen
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (a *Adaptor) DoRequest(c *gin.Context, info *relaycommon.RelayInfo, requestBody io.Reader) (*http.Response, error) {
 | 
			
		||||
	log.Printf("requestBody: %v", requestBody)
 | 
			
		||||
	return channel.DoApiRequest(a, c, info, requestBody)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -48,6 +48,9 @@ func requestOpenAI2Cohere(textRequest dto.GeneralOpenAIRequest) *CohereRequest {
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func requestConvertRerank2Cohere(rerankRequest dto.RerankRequest) *CohereRerankRequest {
 | 
			
		||||
	if rerankRequest.TopN == 0 {
 | 
			
		||||
		rerankRequest.TopN = 1
 | 
			
		||||
	}
 | 
			
		||||
	cohereReq := CohereRerankRequest{
 | 
			
		||||
		Query:           rerankRequest.Query,
 | 
			
		||||
		Documents:       rerankRequest.Documents,
 | 
			
		||||
@@ -55,9 +58,6 @@ func requestConvertRerank2Cohere(rerankRequest dto.RerankRequest) *CohereRerankR
 | 
			
		||||
		TopN:            rerankRequest.TopN,
 | 
			
		||||
		ReturnDocuments: true,
 | 
			
		||||
	}
 | 
			
		||||
	for _, doc := range rerankRequest.Documents {
 | 
			
		||||
		cohereReq.Documents = append(cohereReq.Documents, doc)
 | 
			
		||||
	}
 | 
			
		||||
	return &cohereReq
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user