fix: allow reranking models configured with known_usecases (#8681)

When a model is configured with 'known_usecases: [rerank]' in the YAML
config, the reranking endpoint was not being matched because:
1. The GuessUsecases function only checked for backend == 'rerankers'
2. The syncKnownUsecasesFromString() was not being called when loading
   configs via yaml.Unmarshal in readModelConfigsFromFile

This fix:
1. Updates GuessUsecases to also check if Reranking is explicitly set to
   true in the model config (in addition to checking backend type)
2. Adds syncKnownUsecasesFromString() calls after yaml.Unmarshal in
   readModelConfigsFromFile to ensure known_usecases are properly parsed

Fixes #8658

Signed-off-by: localai-bot <localai-bot@users.noreply.github.com>
Co-authored-by: localai-bot <localai-bot@users.noreply.github.com>
This commit is contained in:
LocalAI [bot]
2026-03-02 19:00:18 +01:00
committed by GitHub
parent 8f0c3cec39
commit 6d182281cf
2 changed files with 3 additions and 1 deletions

View File

@@ -652,7 +652,7 @@ func (c *ModelConfig) GuessUsecases(u ModelConfigUsecase) bool {
}
if (u & FLAG_RERANK) == FLAG_RERANK {
if c.Backend != "rerankers" {
if c.Backend != "rerankers" && (c.Reranking == nil || !*c.Reranking) {
return false
}
}

View File

@@ -91,6 +91,7 @@ func readModelConfigsFromFile(file string, opts ...ConfigLoaderOption) ([]*Model
for _, cc := range configs {
cc.modelConfigFile = file
cc.SetDefaults(opts...)
cc.syncKnownUsecasesFromString()
}
return configs, nil
}
@@ -102,6 +103,7 @@ func readModelConfigsFromFile(file string, opts ...ConfigLoaderOption) ([]*Model
}
c.modelConfigFile = file
c.syncKnownUsecasesFromString()
c.SetDefaults(opts...)
return []*ModelConfig{c}, nil