refactor(gemini): 更新 GeminiModelsResponse 以使用 dto.GeminiModel 类型
This commit is contained in:
@@ -1366,18 +1366,8 @@ func GeminiImageHandler(c *gin.Context, info *relaycommon.RelayInfo, resp *http.
|
|||||||
return usage, nil
|
return usage, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
type GeminiModelInfo struct {
|
|
||||||
Name string `json:"name"`
|
|
||||||
Version string `json:"version"`
|
|
||||||
DisplayName string `json:"displayName"`
|
|
||||||
Description string `json:"description"`
|
|
||||||
InputTokenLimit int `json:"inputTokenLimit"`
|
|
||||||
OutputTokenLimit int `json:"outputTokenLimit"`
|
|
||||||
SupportedGenerationMethods []string `json:"supportedGenerationMethods"`
|
|
||||||
}
|
|
||||||
|
|
||||||
type GeminiModelsResponse struct {
|
type GeminiModelsResponse struct {
|
||||||
Models []GeminiModelInfo `json:"models"`
|
Models []dto.GeminiModel `json:"models"`
|
||||||
NextPageToken string `json:"nextPageToken"`
|
NextPageToken string `json:"nextPageToken"`
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1432,7 +1422,11 @@ func FetchGeminiModels(baseURL, apiKey, proxyURL string) ([]string, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for _, model := range modelsResponse.Models {
|
for _, model := range modelsResponse.Models {
|
||||||
modelName := strings.TrimPrefix(model.Name, "models/")
|
modelNameValue, ok := model.Name.(string)
|
||||||
|
if !ok {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
modelName := strings.TrimPrefix(modelNameValue, "models/")
|
||||||
allModels = append(allModels, modelName)
|
allModels = append(allModels, modelName)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user