Ver Fonte

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.
Seefs há 2 semanas atrás
pai
commit
7da04be52b

+ 1 - 1
common/endpoint_defaults.go

@@ -21,7 +21,7 @@ var defaultEndpointInfoMap = map[constant.EndpointType]EndpointInfo{
 	constant.EndpointTypeOpenAIResponse:  {Path: "/v1/responses", Method: "POST"},
 	constant.EndpointTypeAnthropic:       {Path: "/v1/messages", Method: "POST"},
 	constant.EndpointTypeGemini:          {Path: "/v1beta/models/{model}:generateContent", Method: "POST"},
-	constant.EndpointTypeJinaRerank:      {Path: "/rerank", Method: "POST"},
+	constant.EndpointTypeJinaRerank:      {Path: "/v1/rerank", Method: "POST"},
 	constant.EndpointTypeImageGeneration: {Path: "/v1/images/generations", Method: "POST"},
 	constant.EndpointTypeEmbeddings:      {Path: "/v1/embeddings", Method: "POST"},
 }

+ 16 - 2
controller/channel-test.go

@@ -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"}]`),
 		}
 	}
 

+ 1 - 1
web/src/components/table/channels/modals/ModelTestModal.jsx

@@ -71,7 +71,7 @@ const ModelTestModal = ({
       value: 'gemini',
       label: 'Gemini (/v1beta/models/{model}:generateContent)',
     },
-    { value: 'jina-rerank', label: 'Jina Rerank (/rerank)' },
+    { value: 'jina-rerank', label: 'Jina Rerank (/v1/rerank)' },
     {
       value: 'image-generation',
       label: t('图像生成') + ' (/v1/images/generations)',

+ 1 - 1
web/src/components/table/models/modals/EditModelModal.jsx

@@ -47,7 +47,7 @@ const ENDPOINT_TEMPLATE = {
   'openai-response': { path: '/v1/responses', method: 'POST' },
   anthropic: { path: '/v1/messages', method: 'POST' },
   gemini: { path: '/v1beta/models/{model}:generateContent', method: 'POST' },
-  'jina-rerank': { path: '/rerank', method: 'POST' },
+  'jina-rerank': { path: '/v1/rerank', method: 'POST' },
   'image-generation': { path: '/v1/images/generations', method: 'POST' },
 };
 

+ 1 - 1
web/src/components/table/models/modals/EditPrefillGroupModal.jsx

@@ -45,7 +45,7 @@ const ENDPOINT_TEMPLATE = {
   'openai-response': { path: '/v1/responses', method: 'POST' },
   anthropic: { path: '/v1/messages', method: 'POST' },
   gemini: { path: '/v1beta/models/{model}:generateContent', method: 'POST' },
-  'jina-rerank': { path: '/rerank', method: 'POST' },
+  'jina-rerank': { path: '/v1/rerank', method: 'POST' },
   'image-generation': { path: '/v1/images/generations', method: 'POST' },
 };