(models []T, ownedBy, modelType string)
| 2483 | } |
| 2484 | |
| 2485 | func buildConfigModels[T modelEntry](models []T, ownedBy, modelType string) []*ModelInfo { |
| 2486 | if len(models) == 0 { |
| 2487 | return nil |
| 2488 | } |
| 2489 | now := time.Now().Unix() |
| 2490 | out := make([]*ModelInfo, 0, len(models)) |
| 2491 | seen := make(map[string]struct{}, len(models)) |
| 2492 | for i := range models { |
| 2493 | model := models[i] |
| 2494 | name := strings.TrimSpace(model.GetName()) |
| 2495 | alias := strings.TrimSpace(model.GetAlias()) |
| 2496 | if alias == "" { |
| 2497 | alias = name |
| 2498 | } |
| 2499 | if alias == "" { |
| 2500 | continue |
| 2501 | } |
| 2502 | key := strings.ToLower(alias) |
| 2503 | if _, exists := seen[key]; exists { |
| 2504 | continue |
| 2505 | } |
| 2506 | seen[key] = struct{}{} |
| 2507 | display := name |
| 2508 | if display == "" { |
| 2509 | display = alias |
| 2510 | } |
| 2511 | info := &ModelInfo{ |
| 2512 | ID: alias, |
| 2513 | Object: "model", |
| 2514 | Created: now, |
| 2515 | OwnedBy: ownedBy, |
| 2516 | Type: modelType, |
| 2517 | DisplayName: display, |
| 2518 | UserDefined: true, |
| 2519 | } |
| 2520 | if name != "" { |
| 2521 | if upstream := registry.LookupStaticModelInfo(name); upstream != nil && upstream.Thinking != nil { |
| 2522 | info.Thinking = upstream.Thinking |
| 2523 | } |
| 2524 | } |
| 2525 | out = append(out, info) |
| 2526 | } |
| 2527 | return out |
| 2528 | } |
| 2529 | |
| 2530 | func buildVertexCompatConfigModels(entry *config.VertexCompatKey) []*ModelInfo { |
| 2531 | if entry == nil { |
no test coverage detected