From 524d4a65bf51c03f35335ae0a55e865babb641e1 Mon Sep 17 00:00:00 2001 From: zkp <2470904132@qq.com> Date: Tue, 8 Apr 2025 22:43:13 +0800 Subject: [PATCH] Update: Gemini channel fetch_models --- controller/channel.go | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/controller/channel.go b/controller/channel.go index f3ec6b3a..ad85fe24 100644 --- a/controller/channel.go +++ b/controller/channel.go @@ -119,6 +119,9 @@ func FetchUpstreamModels(c *gin.Context) { baseURL = channel.GetBaseURL() } url := fmt.Sprintf("%s/v1/models", baseURL) + if channel.Type == common.ChannelTypeGemini { + url = fmt.Sprintf("%s/v1beta/openai/models", baseURL) + } body, err := GetResponseBody("GET", url, channel, GetAuthHeader(channel.Key)) if err != nil { c.JSON(http.StatusOK, gin.H{ @@ -139,7 +142,11 @@ func FetchUpstreamModels(c *gin.Context) { var ids []string for _, model := range result.Data { - ids = append(ids, model.ID) + id := model.ID + if channel.Type == common.ChannelTypeGemini { + id = strings.TrimPrefix(id, "models/") + } + ids = append(ids, id) } c.JSON(http.StatusOK, gin.H{