Skip to content

Commit 5303d8a

Browse files
localai-botteam-coding-agent-2
authored andcommitted
fix: allow reranking models configured with known_usecases (mudler#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 mudler#8658 Signed-off-by: localai-bot <localai-bot@users.noreply.github.com> Co-authored-by: localai-bot <localai-bot@users.noreply.github.com>
1 parent 44976d4 commit 5303d8a

2 files changed

Lines changed: 3 additions & 1 deletion

File tree

core/config/model_config.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -652,7 +652,7 @@ func (c *ModelConfig) GuessUsecases(u ModelConfigUsecase) bool {
652652

653653
}
654654
if (u & FLAG_RERANK) == FLAG_RERANK {
655-
if c.Backend != "rerankers" {
655+
if c.Backend != "rerankers" && (c.Reranking == nil || !*c.Reranking) {
656656
return false
657657
}
658658
}

core/config/model_config_loader.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@ func readModelConfigsFromFile(file string, opts ...ConfigLoaderOption) ([]*Model
9191
for _, cc := range configs {
9292
cc.modelConfigFile = file
9393
cc.SetDefaults(opts...)
94+
cc.syncKnownUsecasesFromString()
9495
}
9596
return configs, nil
9697
}
@@ -102,6 +103,7 @@ func readModelConfigsFromFile(file string, opts ...ConfigLoaderOption) ([]*Model
102103
}
103104

104105
c.modelConfigFile = file
106+
c.syncKnownUsecasesFromString()
105107
c.SetDefaults(opts...)
106108

107109
return []*ModelConfig{c}, nil

0 commit comments

Comments
 (0)