mirror of
https://github.com/router-for-me/CLIProxyAPI.git
synced 2026-02-03 04:50:52 +08:00
feat(registry): add client model support check for executor filtering
- Introduced `ClientSupportsModel` function to `ModelRegistry` for verifying client support for specific models. - Integrated model support validation into executor candidate filtering logic. - Updated CLIProxy registry interface to include the new support check method.
This commit is contained in:
@@ -523,6 +523,31 @@ func (r *ModelRegistry) ResumeClientModel(clientID, modelID string) {
|
||||
log.Debugf("Resumed client %s for model %s", clientID, modelID)
|
||||
}
|
||||
|
||||
// ClientSupportsModel reports whether the client registered support for modelID.
|
||||
func (r *ModelRegistry) ClientSupportsModel(clientID, modelID string) bool {
|
||||
clientID = strings.TrimSpace(clientID)
|
||||
modelID = strings.TrimSpace(modelID)
|
||||
if clientID == "" || modelID == "" {
|
||||
return false
|
||||
}
|
||||
|
||||
r.mutex.RLock()
|
||||
defer r.mutex.RUnlock()
|
||||
|
||||
models, exists := r.clientModels[clientID]
|
||||
if !exists || len(models) == 0 {
|
||||
return false
|
||||
}
|
||||
|
||||
for _, id := range models {
|
||||
if strings.EqualFold(strings.TrimSpace(id), modelID) {
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
// GetAvailableModels returns all models that have at least one available client
|
||||
// Parameters:
|
||||
// - handlerType: The handler type to filter models for (e.g., "openai", "claude", "gemini")
|
||||
|
||||
Reference in New Issue
Block a user