chore: Simplify utils/token.rs:get_token()
#328
Merged
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.
Presently when a token is not considered valid via this utility method, it is treated as an empty string
Some("")
to hand over to thehf-hub
crate API, but it should have instead been provided asNone
?From the
hf-hub
crate, you can see that this would avoid adding a blank authorization HTTP headerThis PR change won't avoid this info log showing multiple times however:
Which is due to calling
ApiBuilder::new()
which initializes by checking a cache dir path for atoken
file (viacache.token()
)Added context
Since
mistral.rs
is already setting the token viawith_token()
the upstream internalcache.token()
seems redundant? But would presently require recreatingfrom_cache()
without thecache.token()
line and providing a defaultCache
input:UPDATE: I've sent a PR upstream to address that, however it doesn't look like the crate is being maintained? Simple to review contributions already exist but have had no response.