feat(ai-proxy): add anthropic && gemini apiName (#2551)

Signed-off-by: Xijun Dai <daixijun1990@gmail.com>
This commit is contained in:
Xijun Dai
2025-07-15 19:15:07 +08:00
committed by GitHub
parent 081ab6ee8d
commit c3eb8d0447
5 changed files with 76 additions and 37 deletions

View File

@@ -9,10 +9,10 @@ import (
"time"
"github.com/alibaba/higress/plugins/wasm-go/extensions/ai-proxy/util"
"github.com/higress-group/wasm-go/pkg/log"
"github.com/higress-group/wasm-go/pkg/wrapper"
"github.com/google/uuid"
"github.com/higress-group/proxy-wasm-go-sdk/proxywasm/types"
"github.com/higress-group/wasm-go/pkg/log"
"github.com/higress-group/wasm-go/pkg/wrapper"
)
// geminiProvider is the provider for google gemini/gemini flash service.
@@ -39,10 +39,12 @@ func (g *geminiProviderInitializer) ValidateConfig(config *ProviderConfig) error
func (g *geminiProviderInitializer) DefaultCapabilities() map[string]string {
return map[string]string{
string(ApiNameChatCompletion): "",
string(ApiNameEmbeddings): "",
string(ApiNameModels): "",
string(ApiNameImageGeneration): "",
string(ApiNameChatCompletion): "",
string(ApiNameEmbeddings): "",
string(ApiNameModels): "",
string(ApiNameImageGeneration): "",
string(ApiNameGeminiGenerateContent): "",
string(ApiNameGeminiStreamGenerateContent): "",
}
}
@@ -91,6 +93,7 @@ func (g *geminiProvider) TransformRequestBodyHeaders(ctx wrapper.HttpContext, ap
case ApiNameImageGeneration:
return g.onImageGenerationRequestBody(ctx, body, headers)
}
log.Debugf("TransformRequestBodyHeaders apiName:%s", apiName)
return body, nil
}
@@ -259,6 +262,10 @@ func (g *geminiProvider) getRequestPath(apiName ApiName, model string, stream bo
}
case ApiNameImageGeneration:
action = geminiImageGenerationPath
case ApiNameGeminiGenerateContent:
action = geminiChatCompletionPath
case ApiNameGeminiStreamGenerateContent:
action = geminiChatCompletionStreamPath
}
return fmt.Sprintf("/%s/models/%s:%s", g.config.apiVersion, model, action)
}