|
4 | 4 | "fmt" |
5 | 5 | "os" |
6 | 6 | "path/filepath" |
| 7 | + "slices" |
7 | 8 | "sync" |
8 | 9 |
|
9 | 10 | "gopkg.in/yaml.v3" |
@@ -439,14 +440,7 @@ func (c *RouterConfig) IsModelAllowedForPIIType(modelName string, piiType string |
439 | 440 | } |
440 | 441 |
|
441 | 442 | // If allow_by_default is false, only explicitly allowed PII types are permitted |
442 | | - for _, allowedPII := range policy.PIITypes { |
443 | | - if allowedPII == piiType { |
444 | | - return true |
445 | | - } |
446 | | - } |
447 | | - |
448 | | - // PII type not found in allowed list and allow_by_default is false |
449 | | - return false |
| 443 | + return slices.Contains(policy.PIITypes, piiType) |
450 | 444 | } |
451 | 445 |
|
452 | 446 | // IsModelAllowedForPIITypes checks if a model is allowed to process any of the given PII types |
@@ -487,23 +481,17 @@ func (c *RouterConfig) GetEndpointsForModel(modelName string) []VLLMEndpoint { |
487 | 481 |
|
488 | 482 | // First, find all endpoints that can serve this model |
489 | 483 | for _, endpoint := range c.VLLMEndpoints { |
490 | | - for _, model := range endpoint.Models { |
491 | | - if model == modelName { |
492 | | - availableEndpoints = append(availableEndpoints, endpoint) |
493 | | - break |
494 | | - } |
| 484 | + if slices.Contains(endpoint.Models, modelName) { |
| 485 | + availableEndpoints = append(availableEndpoints, endpoint) |
495 | 486 | } |
496 | 487 | } |
497 | 488 |
|
498 | 489 | // Check if model has preferred endpoints configured |
499 | 490 | if modelConfig, ok := c.ModelConfig[modelName]; ok && len(modelConfig.PreferredEndpoints) > 0 { |
500 | 491 | var preferredEndpoints []VLLMEndpoint |
501 | 492 | for _, endpoint := range availableEndpoints { |
502 | | - for _, preferredName := range modelConfig.PreferredEndpoints { |
503 | | - if endpoint.Name == preferredName { |
504 | | - preferredEndpoints = append(preferredEndpoints, endpoint) |
505 | | - break |
506 | | - } |
| 493 | + if slices.Contains(modelConfig.PreferredEndpoints, endpoint.Name) { |
| 494 | + preferredEndpoints = append(preferredEndpoints, endpoint) |
507 | 495 | } |
508 | 496 | } |
509 | 497 | if len(preferredEndpoints) > 0 { |
|
0 commit comments