mirror of
https://github.com/QuantumNous/new-api.git
synced 2026-04-18 03:57:27 +00:00
fix: test using the correct path for rerank (#2736)
* fix: test using the correct path for rerank. * fix: The `input` parameter for testing responses uses an array to accommodate certain channels, such as Codex, which are incompatible with single strings.
This commit is contained in:
@@ -84,6 +84,11 @@ func testChannel(channel *model.Channel, testModel string, endpointType string)
|
||||
}
|
||||
} else {
|
||||
// 如果没有指定端点类型,使用原有的自动检测逻辑
|
||||
|
||||
if strings.Contains(strings.ToLower(testModel), "rerank") {
|
||||
requestPath = "/v1/rerank"
|
||||
}
|
||||
|
||||
// 先判断是否为 Embedding 模型
|
||||
if strings.Contains(strings.ToLower(testModel), "embedding") ||
|
||||
strings.HasPrefix(testModel, "m3e") || // m3e 系列模型
|
||||
@@ -456,7 +461,7 @@ func buildTestRequest(model string, endpointType string, channel *model.Channel)
|
||||
// 返回 OpenAIResponsesRequest
|
||||
return &dto.OpenAIResponsesRequest{
|
||||
Model: model,
|
||||
Input: json.RawMessage("\"hi\""),
|
||||
Input: json.RawMessage(`[{"role":"user","content":"hi"}]`),
|
||||
}
|
||||
case constant.EndpointTypeAnthropic, constant.EndpointTypeGemini, constant.EndpointTypeOpenAI:
|
||||
// 返回 GeneralOpenAIRequest
|
||||
@@ -479,6 +484,15 @@ func buildTestRequest(model string, endpointType string, channel *model.Channel)
|
||||
}
|
||||
|
||||
// 自动检测逻辑(保持原有行为)
|
||||
if strings.Contains(strings.ToLower(model), "rerank") {
|
||||
return &dto.RerankRequest{
|
||||
Model: model,
|
||||
Query: "What is Deep Learning?",
|
||||
Documents: []any{"Deep Learning is a subset of machine learning.", "Machine learning is a field of artificial intelligence."},
|
||||
TopN: 2,
|
||||
}
|
||||
}
|
||||
|
||||
// 先判断是否为 Embedding 模型
|
||||
if strings.Contains(strings.ToLower(model), "embedding") ||
|
||||
strings.HasPrefix(model, "m3e") ||
|
||||
@@ -494,7 +508,7 @@ func buildTestRequest(model string, endpointType string, channel *model.Channel)
|
||||
if strings.Contains(strings.ToLower(model), "codex") {
|
||||
return &dto.OpenAIResponsesRequest{
|
||||
Model: model,
|
||||
Input: json.RawMessage("\"hi\""),
|
||||
Input: json.RawMessage(`[{"role":"user","content":"hi"}]`),
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user