Commit ae6f3bc
* Fix inconsistent top_k validation in SentenceTransformersDiversityRanker
- change elif to if in run() method to ensure top_k validation always
runs regardless of whatever top_k comes from init or runtime
- Both scenarios now consistently raise ValueError with descriptive
message format: 'top_k must be between 1 and X, but got Y'
- Fixes inconsistency where init top_k gave confusing MMR error while
runtime top_k gave clear validation error
* improvements
---------
Co-authored-by: Stefano Fiorucci <stefanofiorucci@gmail.com>
1 parent 9ce48f9 commit ae6f3bc
3 files changed
Lines changed: 11 additions & 7 deletions
File tree
- haystack/components/rankers
- releasenotes/notes
- test/components/rankers
Lines changed: 5 additions & 6 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
353 | 353 | | |
354 | 354 | | |
355 | 355 | | |
356 | | - | |
| 356 | + | |
357 | 357 | | |
358 | 358 | | |
359 | 359 | | |
| |||
375 | 375 | | |
376 | 376 | | |
377 | 377 | | |
378 | | - | |
379 | | - | |
380 | | - | |
| 378 | + | |
| 379 | + | |
381 | 380 | | |
382 | 381 | | |
383 | 382 | | |
| |||
421 | 420 | | |
422 | 421 | | |
423 | 422 | | |
424 | | - | |
425 | | - | |
| 423 | + | |
| 424 | + | |
426 | 425 | | |
427 | 426 | | |
428 | 427 | | |
| |||
Lines changed: 5 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
Lines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
381 | 381 | | |
382 | 382 | | |
383 | 383 | | |
384 | | - | |
| 384 | + | |
385 | 385 | | |
386 | 386 | | |
387 | 387 | | |
| |||
0 commit comments