fix:path rewriting & model list
This commit is contained in:
@@ -62,10 +62,13 @@ func (ch *GeminiChannel) extractModelFromRequest(c *gin.Context, bodyBytes []byt
|
||||
var p struct {
|
||||
Model string `json:"model"`
|
||||
}
|
||||
if json.Unmarshal(bodyBytes, &p) == nil && p.Model != "" {
|
||||
return strings.TrimPrefix(p.Model, "models/")
|
||||
_ = json.Unmarshal(bodyBytes, &p)
|
||||
modelName := strings.TrimPrefix(p.Model, "models/")
|
||||
|
||||
if modelName == "" {
|
||||
modelName = ch.extractModelFromPath(c.Request.URL.Path)
|
||||
}
|
||||
return ch.extractModelFromPath(c.Request.URL.Path)
|
||||
return modelName
|
||||
}
|
||||
|
||||
func (ch *GeminiChannel) extractModelFromPath(path string) string {
|
||||
@@ -85,7 +88,11 @@ func (ch *GeminiChannel) IsOpenAICompatibleRequest(c *gin.Context) bool {
|
||||
}
|
||||
|
||||
func (ch *GeminiChannel) isOpenAIPath(path string) bool {
|
||||
return strings.Contains(path, "/v1/chat/completions") || strings.Contains(path, "/v1/embeddings")
|
||||
return strings.Contains(path, "/v1/chat/completions") ||
|
||||
strings.Contains(path, "/v1/completions") ||
|
||||
strings.Contains(path, "/v1/embeddings") ||
|
||||
strings.Contains(path, "/v1/models") ||
|
||||
strings.Contains(path, "/v1/audio/")
|
||||
}
|
||||
|
||||
func (ch *GeminiChannel) ValidateKey(
|
||||
|
||||
Reference in New Issue
Block a user