mirror of
https://git.datalinker.icu/vllm-project/vllm.git
synced 2026-07-29 18:47:58 +08:00
[Misc] add handler HF_TOKEN is emptry string (#20369)
Signed-off-by: rongfu.leng <rongfu.leng@daocloud.io>
This commit is contained in:
parent
d265414dbc
commit
139508a418
@ -56,6 +56,22 @@ MISTRAL_CONFIG_NAME = "params.json"
|
|||||||
|
|
||||||
logger = init_logger(__name__)
|
logger = init_logger(__name__)
|
||||||
|
|
||||||
|
|
||||||
|
def _get_hf_token() -> Optional[str]:
|
||||||
|
"""
|
||||||
|
Get the HuggingFace token from environment variable.
|
||||||
|
|
||||||
|
Returns None if the token is not set, is an empty string,
|
||||||
|
or contains only whitespace.
|
||||||
|
This follows the same pattern as huggingface_hub library which
|
||||||
|
treats empty string tokens as None to avoid authentication errors.
|
||||||
|
"""
|
||||||
|
token = os.getenv('HF_TOKEN')
|
||||||
|
if token and token.strip():
|
||||||
|
return token
|
||||||
|
return None
|
||||||
|
|
||||||
|
|
||||||
_CONFIG_REGISTRY_OVERRIDE_HF: dict[str, type[PretrainedConfig]] = {
|
_CONFIG_REGISTRY_OVERRIDE_HF: dict[str, type[PretrainedConfig]] = {
|
||||||
"mllama": MllamaConfig
|
"mllama": MllamaConfig
|
||||||
}
|
}
|
||||||
@ -195,7 +211,7 @@ def file_or_path_exists(model: Union[str, Path], config_name: str,
|
|||||||
return file_exists(str(model),
|
return file_exists(str(model),
|
||||||
config_name,
|
config_name,
|
||||||
revision=revision,
|
revision=revision,
|
||||||
token=os.getenv('HF_TOKEN', None))
|
token=_get_hf_token())
|
||||||
|
|
||||||
|
|
||||||
def patch_rope_scaling(config: PretrainedConfig) -> None:
|
def patch_rope_scaling(config: PretrainedConfig) -> None:
|
||||||
@ -322,7 +338,7 @@ def get_config(
|
|||||||
model,
|
model,
|
||||||
revision=revision,
|
revision=revision,
|
||||||
code_revision=code_revision,
|
code_revision=code_revision,
|
||||||
token=os.getenv('HF_TOKEN', None),
|
token=_get_hf_token(),
|
||||||
**kwargs,
|
**kwargs,
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -334,7 +350,7 @@ def get_config(
|
|||||||
model,
|
model,
|
||||||
revision=revision,
|
revision=revision,
|
||||||
code_revision=code_revision,
|
code_revision=code_revision,
|
||||||
token=os.getenv('HF_TOKEN', None),
|
token=_get_hf_token(),
|
||||||
**kwargs,
|
**kwargs,
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
@ -344,7 +360,7 @@ def get_config(
|
|||||||
trust_remote_code=trust_remote_code,
|
trust_remote_code=trust_remote_code,
|
||||||
revision=revision,
|
revision=revision,
|
||||||
code_revision=code_revision,
|
code_revision=code_revision,
|
||||||
token=os.getenv('HF_TOKEN', None),
|
token=_get_hf_token(),
|
||||||
**kwargs,
|
**kwargs,
|
||||||
)
|
)
|
||||||
except ValueError as e:
|
except ValueError as e:
|
||||||
@ -571,7 +587,7 @@ def get_sentence_transformer_tokenizer_config(model: str,
|
|||||||
# If model is on HuggingfaceHub, get the repo files
|
# If model is on HuggingfaceHub, get the repo files
|
||||||
repo_files = list_repo_files(model,
|
repo_files = list_repo_files(model,
|
||||||
revision=revision,
|
revision=revision,
|
||||||
token=os.getenv('HF_TOKEN', None))
|
token=_get_hf_token())
|
||||||
except Exception:
|
except Exception:
|
||||||
repo_files = []
|
repo_files = []
|
||||||
|
|
||||||
@ -862,7 +878,7 @@ def try_get_safetensors_metadata(
|
|||||||
get_safetensors_metadata,
|
get_safetensors_metadata,
|
||||||
model,
|
model,
|
||||||
revision=revision,
|
revision=revision,
|
||||||
token=os.getenv('HF_TOKEN', None),
|
token=_get_hf_token(),
|
||||||
)
|
)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user