feat(ai-proxy): support Qwen reranks and conversations paths (#3724)

This commit is contained in:
woody
2026-04-16 15:52:58 +08:00
committed by GitHub
parent 26e17c48eb
commit 94b40aab9a
5 changed files with 185 additions and 3 deletions

View File

@@ -71,6 +71,7 @@ const (
ApiNameQwenAsyncAIGC ApiName = "qwen/v1/services/aigc"
ApiNameQwenAsyncTask ApiName = "qwen/v1/tasks"
ApiNameQwenV1Rerank ApiName = "qwen/v1/rerank"
ApiNameQwenV1Conversations ApiName = "qwen/v1/conversations"
ApiNameGeminiGenerateContent ApiName = "gemini/v1beta/generatecontent"
ApiNameGeminiStreamGenerateContent ApiName = "gemini/v1beta/streamgeneratecontent"
ApiNameAnthropicMessages ApiName = "anthropic/v1/messages"
@@ -118,6 +119,10 @@ const (
// Cohere
PathCohereV1Rerank = "/v1/rerank"
// Qwen
PathQwenV1Reranks = "/v1/reranks"
PathQwenV1Conversations = "/v1/conversations"
providerTypeMoonshot = "moonshot"
providerTypeAzure = "azure"
providerTypeAi360 = "ai360"

View File

@@ -27,9 +27,11 @@ const (
qwenChatCompletionPath = "/api/v1/services/aigc/text-generation/generation"
qwenTextEmbeddingPath = "/api/v1/services/embeddings/text-embedding/text-embedding"
qwenTextRerankPath = "/api/v1/services/rerank/text-rerank/text-rerank"
qwenCompatibleTextRerankPath = "/compatible-api/v1/reranks"
qwenCompatibleChatCompletionPath = "/compatible-mode/v1/chat/completions"
qwenCompatibleCompletionsPath = "/compatible-mode/v1/completions"
qwenCompatibleTextEmbeddingPath = "/compatible-mode/v1/embeddings"
qwenCompatibleConversationsPath = "/compatible-mode/v1/conversations"
qwenCompatibleResponsesPath = "/compatible-mode/v1/responses"
qwenCompatibleFilesPath = "/compatible-mode/v1/files"
qwenCompatibleRetrieveFilePath = "/compatible-mode/v1/files/{file_id}"
@@ -78,7 +80,8 @@ func (m *qwenProviderInitializer) DefaultCapabilities(qwenEnableCompatible bool)
string(ApiNameRetrieveBatch): qwenCompatibleRetrieveBatchPath,
string(ApiNameQwenAsyncAIGC): qwenAsyncAIGCPath,
string(ApiNameQwenAsyncTask): qwenAsyncTaskPath,
string(ApiNameQwenV1Rerank): qwenTextRerankPath,
string(ApiNameQwenV1Rerank): qwenCompatibleTextRerankPath,
string(ApiNameQwenV1Conversations): qwenCompatibleConversationsPath,
string(ApiNameAnthropicMessages): qwenAnthropicMessagesPath,
}
} else {
@@ -715,8 +718,11 @@ func (m *qwenProvider) GetApiName(path string) ApiName {
return ApiNameQwenAsyncAIGC
case strings.Contains(path, qwenAsyncTaskPath):
return ApiNameQwenAsyncTask
case strings.Contains(path, qwenTextRerankPath):
case strings.Contains(path, qwenTextRerankPath),
strings.Contains(path, qwenCompatibleTextRerankPath):
return ApiNameQwenV1Rerank
case strings.Contains(path, qwenCompatibleConversationsPath):
return ApiNameQwenV1Conversations
default:
return ""
}