Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion common/endpoint_defaults.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"},
}
Expand Down
18 changes: 16 additions & 2 deletions controller/channel-test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 系列模型
Expand Down Expand Up @@ -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
Expand All @@ -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") ||
Expand All @@ -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"}]`),
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)',
Expand Down
2 changes: 1 addition & 1 deletion web/src/components/table/models/modals/EditModelModal.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -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' },
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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' },
};

Expand Down