NormalizeExcludedModels trims, lowercases, and deduplicates model exclusion patterns. It preserves the order of first occurrences and drops empty entries.
(models []string)
| 1125 | // NormalizeExcludedModels trims, lowercases, and deduplicates model exclusion patterns. |
| 1126 | // It preserves the order of first occurrences and drops empty entries. |
| 1127 | func NormalizeExcludedModels(models []string) []string { |
| 1128 | if len(models) == 0 { |
| 1129 | return nil |
| 1130 | } |
| 1131 | seen := make(map[string]struct{}, len(models)) |
| 1132 | out := make([]string, 0, len(models)) |
| 1133 | for _, raw := range models { |
| 1134 | trimmed := strings.ToLower(strings.TrimSpace(raw)) |
| 1135 | if trimmed == "" { |
| 1136 | continue |
| 1137 | } |
| 1138 | if _, exists := seen[trimmed]; exists { |
| 1139 | continue |
| 1140 | } |
| 1141 | seen[trimmed] = struct{}{} |
| 1142 | out = append(out, trimmed) |
| 1143 | } |
| 1144 | if len(out) == 0 { |
| 1145 | return nil |
| 1146 | } |
| 1147 | return out |
| 1148 | } |
| 1149 | |
| 1150 | // NormalizeOAuthExcludedModels cleans provider -> excluded models mappings by normalizing provider keys |
| 1151 | // and applying model exclusion normalization to each entry. |
no outgoing calls
no test coverage detected