mirror of
https://github.com/alibaba/higress.git
synced 2026-06-26 02:35:02 +08:00
feat: Support /v1/models API in ai-proxy (#2164)
This commit is contained in:
@@ -358,6 +358,9 @@ func getApiName(path string) provider.ApiName {
|
|||||||
if strings.HasSuffix(path, "/v1/files") {
|
if strings.HasSuffix(path, "/v1/files") {
|
||||||
return provider.ApiNameFiles
|
return provider.ApiNameFiles
|
||||||
}
|
}
|
||||||
|
if strings.HasSuffix(path, "/v1/models") {
|
||||||
|
return provider.ApiNameModels
|
||||||
|
}
|
||||||
// cohere style
|
// cohere style
|
||||||
if strings.HasSuffix(path, "/v1/rerank") {
|
if strings.HasSuffix(path, "/v1/rerank") {
|
||||||
return provider.ApiNameCohereV1Rerank
|
return provider.ApiNameCohereV1Rerank
|
||||||
|
|||||||
@@ -20,6 +20,7 @@ import (
|
|||||||
const (
|
const (
|
||||||
moonshotDomain = "api.moonshot.cn"
|
moonshotDomain = "api.moonshot.cn"
|
||||||
moonshotChatCompletionPath = "/v1/chat/completions"
|
moonshotChatCompletionPath = "/v1/chat/completions"
|
||||||
|
moonshotModelsPath = "/v1/models"
|
||||||
)
|
)
|
||||||
|
|
||||||
type moonshotProviderInitializer struct {
|
type moonshotProviderInitializer struct {
|
||||||
@@ -38,6 +39,7 @@ func (m *moonshotProviderInitializer) ValidateConfig(config *ProviderConfig) err
|
|||||||
func (m *moonshotProviderInitializer) DefaultCapabilities() map[string]string {
|
func (m *moonshotProviderInitializer) DefaultCapabilities() map[string]string {
|
||||||
return map[string]string{
|
return map[string]string{
|
||||||
string(ApiNameChatCompletion): moonshotChatCompletionPath,
|
string(ApiNameChatCompletion): moonshotChatCompletionPath,
|
||||||
|
string(ApiNameModels): moonshotModelsPath,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -30,6 +30,7 @@ func (m *ollamaProviderInitializer) DefaultCapabilities() map[string]string {
|
|||||||
// ollama的chat接口path和OpenAI的chat接口一样
|
// ollama的chat接口path和OpenAI的chat接口一样
|
||||||
string(ApiNameChatCompletion): PathOpenAIChatCompletions,
|
string(ApiNameChatCompletion): PathOpenAIChatCompletions,
|
||||||
string(ApiNameEmbeddings): PathOpenAIEmbeddings,
|
string(ApiNameEmbeddings): PathOpenAIEmbeddings,
|
||||||
|
string(ApiNameModels): PathOpenAIModels,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -21,6 +21,7 @@ const (
|
|||||||
defaultOpenaiEmbeddingsPath = "/v1/embeddings"
|
defaultOpenaiEmbeddingsPath = "/v1/embeddings"
|
||||||
defaultOpenaiAudioSpeech = "/v1/audio/speech"
|
defaultOpenaiAudioSpeech = "/v1/audio/speech"
|
||||||
defaultOpenaiImageGeneration = "/v1/images/generations"
|
defaultOpenaiImageGeneration = "/v1/images/generations"
|
||||||
|
defaultOpenaiModels = "/v1/models"
|
||||||
)
|
)
|
||||||
|
|
||||||
type openaiProviderInitializer struct {
|
type openaiProviderInitializer struct {
|
||||||
@@ -37,6 +38,7 @@ func (m *openaiProviderInitializer) DefaultCapabilities() map[string]string {
|
|||||||
string(ApiNameEmbeddings): defaultOpenaiEmbeddingsPath,
|
string(ApiNameEmbeddings): defaultOpenaiEmbeddingsPath,
|
||||||
string(ApiNameImageGeneration): defaultOpenaiImageGeneration,
|
string(ApiNameImageGeneration): defaultOpenaiImageGeneration,
|
||||||
string(ApiNameAudioSpeech): defaultOpenaiAudioSpeech,
|
string(ApiNameAudioSpeech): defaultOpenaiAudioSpeech,
|
||||||
|
string(ApiNameModels): defaultOpenaiModels,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -31,12 +31,14 @@ const (
|
|||||||
ApiNameAudioSpeech ApiName = "openai/v1/audiospeech"
|
ApiNameAudioSpeech ApiName = "openai/v1/audiospeech"
|
||||||
ApiNameFiles ApiName = "openai/v1/files"
|
ApiNameFiles ApiName = "openai/v1/files"
|
||||||
ApiNameBatches ApiName = "openai/v1/batches"
|
ApiNameBatches ApiName = "openai/v1/batches"
|
||||||
|
ApiNameModels ApiName = "openai/v1/models"
|
||||||
|
|
||||||
PathOpenAICompletions = "/v1/completions"
|
PathOpenAICompletions = "/v1/completions"
|
||||||
PathOpenAIChatCompletions = "/v1/chat/completions"
|
PathOpenAIChatCompletions = "/v1/chat/completions"
|
||||||
PathOpenAIEmbeddings = "/v1/embeddings"
|
PathOpenAIEmbeddings = "/v1/embeddings"
|
||||||
PathOpenAIFiles = "/v1/files"
|
PathOpenAIFiles = "/v1/files"
|
||||||
PathOpenAIBatches = "/v1/batches"
|
PathOpenAIBatches = "/v1/batches"
|
||||||
|
PathOpenAIModels = "/v1/models"
|
||||||
|
|
||||||
// TODO: 以下是一些非标准的API名称,需要进一步确认是否支持
|
// TODO: 以下是一些非标准的API名称,需要进一步确认是否支持
|
||||||
ApiNameCohereV1Rerank ApiName = "cohere/v1/rerank"
|
ApiNameCohereV1Rerank ApiName = "cohere/v1/rerank"
|
||||||
|
|||||||
Reference in New Issue
Block a user