mirror of
https://github.com/router-for-me/CLIProxyAPI.git
synced 2026-02-03 13:00:52 +08:00
Merge pull request #1132 from XYenon/fix/gemini-models-displayname-override
fix(gemini): preserve displayName and description in models list
This commit is contained in:
@@ -997,7 +997,7 @@ func FetchAntigravityModels(ctx context.Context, auth *cliproxyauth.Auth, cfg *c
|
|||||||
now := time.Now().Unix()
|
now := time.Now().Unix()
|
||||||
modelConfig := registry.GetAntigravityModelConfig()
|
modelConfig := registry.GetAntigravityModelConfig()
|
||||||
models := make([]*registry.ModelInfo, 0, len(result.Map()))
|
models := make([]*registry.ModelInfo, 0, len(result.Map()))
|
||||||
for originalName := range result.Map() {
|
for originalName, modelData := range result.Map() {
|
||||||
modelID := strings.TrimSpace(originalName)
|
modelID := strings.TrimSpace(originalName)
|
||||||
if modelID == "" {
|
if modelID == "" {
|
||||||
continue
|
continue
|
||||||
@@ -1007,12 +1007,18 @@ func FetchAntigravityModels(ctx context.Context, auth *cliproxyauth.Auth, cfg *c
|
|||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
modelCfg := modelConfig[modelID]
|
modelCfg := modelConfig[modelID]
|
||||||
modelName := modelID
|
|
||||||
|
// Extract displayName from upstream response, fallback to modelID
|
||||||
|
displayName := modelData.Get("displayName").String()
|
||||||
|
if displayName == "" {
|
||||||
|
displayName = modelID
|
||||||
|
}
|
||||||
|
|
||||||
modelInfo := ®istry.ModelInfo{
|
modelInfo := ®istry.ModelInfo{
|
||||||
ID: modelID,
|
ID: modelID,
|
||||||
Name: modelName,
|
Name: modelID,
|
||||||
Description: modelID,
|
Description: displayName,
|
||||||
DisplayName: modelID,
|
DisplayName: displayName,
|
||||||
Version: modelID,
|
Version: modelID,
|
||||||
Object: "model",
|
Object: "model",
|
||||||
Created: now,
|
Created: now,
|
||||||
|
|||||||
@@ -60,8 +60,12 @@ func (h *GeminiAPIHandler) GeminiModels(c *gin.Context) {
|
|||||||
if !strings.HasPrefix(name, "models/") {
|
if !strings.HasPrefix(name, "models/") {
|
||||||
normalizedModel["name"] = "models/" + name
|
normalizedModel["name"] = "models/" + name
|
||||||
}
|
}
|
||||||
normalizedModel["displayName"] = name
|
if displayName, _ := normalizedModel["displayName"].(string); displayName == "" {
|
||||||
normalizedModel["description"] = name
|
normalizedModel["displayName"] = name
|
||||||
|
}
|
||||||
|
if description, _ := normalizedModel["description"].(string); description == "" {
|
||||||
|
normalizedModel["description"] = name
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if _, ok := normalizedModel["supportedGenerationMethods"]; !ok {
|
if _, ok := normalizedModel["supportedGenerationMethods"]; !ok {
|
||||||
normalizedModel["supportedGenerationMethods"] = defaultMethods
|
normalizedModel["supportedGenerationMethods"] = defaultMethods
|
||||||
|
|||||||
Reference in New Issue
Block a user