fix(knowledge): show platform-accurate valid options in embedding type error#3722
Open
sandikodev wants to merge 1 commit intoaws:mainfrom
Open
fix(knowledge): show platform-accurate valid options in embedding type error#3722sandikodev wants to merge 1 commit intoaws:mainfrom
sandikodev wants to merge 1 commit intoaws:mainfrom
Conversation
…e error On Linux ARM64, EmbeddingType::Best is not available (candle is excluded via cfg). When a user passes --index-type best on that platform, from_str returns None and the error message was: Invalid embedding type 'best'. Valid options are: fast, best This is misleading — 'best' is listed as valid but is not accepted. Use cfg to build the valid options string at compile time so Linux ARM64 shows only 'fast', while other platforms show 'fast, best'. Fixes aws#3139
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Issue
Closes #3139
Problem
On Linux ARM64,
EmbeddingType::Bestis not available — thecandlemodule is excluded via#[cfg(not(all(target_os = "linux", target_arch = "aarch64")))]. When a user passes--index-type beston that platform,from_strcorrectly returnsNone, but the error message was misleading:bestis listed as a valid option but is not accepted on that platform, causing user confusion (as reported in the issue).Fix
Use
cfgto build the valid options string at compile time:On Linux ARM64 the error now reads:
Testing
The test
invalid_embedding_type_error_does_not_mention_best_on_linux_armusescfgto assert platform-specific behaviour:EmbeddingType::from_str("best")returnsNoneand the error message does not mentionbestEmbeddingType::from_str("best")returnsSome(no change in behaviour)By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.