Module: DurableHuggingfaceHub::Constants
- Defined in:
- lib/durable_huggingface_hub/constants.rb
Overview
Constants used throughout the HuggingFace Hub client library.
This module contains URL endpoints, file patterns, timeout values, size limits, and other configuration constants required for interacting with the HuggingFace Hub API.
Constant Summary collapse
- ENDPOINT =
Default HuggingFace Hub endpoint URL
"https://huggingface.co"- HUGGINGFACE_CO_URL_HOME =
HuggingFace Hub home URL
"https://huggingface.co/"- HUGGINGFACE_CO_URL_TEMPLATE =
Template for constructing HuggingFace Hub URLs
"https://huggingface.co/{repo_id}/resolve/{revision}/{filename}"- INFERENCE_ENDPOINT =
Default inference endpoint URL
"https://api-inference.huggingface.co"- INFERENCE_ENDPOINTS_ENDPOINT =
Inference endpoints API URL
"https://api.endpoints.huggingface.cloud/v2"- INFERENCE_CATALOG_ENDPOINT =
Inference catalog endpoint URL
"https://endpoints.huggingface.co/api/catalog"- INFERENCE_PROXY_TEMPLATE =
Inference proxy template
"https://router.huggingface.co/{provider}"- INFERENCE_ENDPOINT_IMAGE_KEYS =
Inference endpoint image keys
[ "custom", "huggingface", "huggingfaceNeuron", "llamacpp", "tei", "tgi", "tgiNeuron" ].freeze
- REPO_ID_SEPARATOR =
Separator used in repository IDs (e.g., organization/model-name)
"/"- DEFAULT_REVISION =
Default revision/branch name for repositories
"main"- REGEX_COMMIT_OID =
Regular expression pattern for validating commit OIDs (Git SHA-1 hashes) Matches 40 hexadecimal characters
/\A[0-9a-f]{40}\z/i- PYTORCH_WEIGHTS_NAME =
File naming conventions for PyTorch models
"pytorch_model.bin"- PYTORCH_WEIGHTS_INDEX_NAME =
"pytorch_model.bin.index.json"- PYTORCH_WEIGHTS_FILE_PATTERN =
"pytorch_model{suffix}.bin"- TF2_WEIGHTS_NAME =
TensorFlow model file names
"tf_model.h5"- TF_WEIGHTS_NAME =
"model.ckpt"- TF2_WEIGHTS_FILE_PATTERN =
"tf_model{suffix}.h5"- FLAX_WEIGHTS_NAME =
Flax model file names
"flax_model.msgpack"- SAFETENSORS_WEIGHTS_FILE_PATTERN =
SafeTensors file patterns (preferred format for model weights)
"model*.safetensors"- SAFETENSORS_WEIGHTS_FILE_PATTERN_SUFFIX =
"model{suffix}.safetensors"- SAFETENSORS_SINGLE_FILE =
"model.safetensors"- SAFETENSORS_INDEX_FILE =
"model.safetensors.index.json"- SAFETENSORS_MAX_HEADER_LENGTH =
25_000_000- CONFIG_NAME =
Configuration and metadata file names
"config.json"- REPOCARD_NAME =
"README.md"- DEFAULT_ETAG_TIMEOUT =
Timeout for ETag validation requests
10- DEFAULT_DOWNLOAD_TIMEOUT =
Timeout for file download operations
600- DEFAULT_REQUEST_TIMEOUT =
Timeout for general API requests
10- DOWNLOAD_CHUNK_SIZE =
Size of chunks for streaming downloads (10 MB)
10 * 1024 * 1024
- MAX_HTTP_DOWNLOAD_SIZE =
Maximum size for HTTP downloads before requiring streaming (50 GB)
50 * 1024 * 1024 * 1024
- LFS_THRESHOLD =
LFS (Large File Storage) threshold - files larger than this use LFS (10 MB)
10 * 1024 * 1024
- FILELOCK_LOG_EVERY_SECONDS =
File lock logging interval (in seconds)
10- REPO_TYPE_MODEL =
Repository type constants
"model"- REPO_TYPE_DATASET =
"dataset"- REPO_TYPE_SPACE =
"space"- REPO_TYPES =
Valid repository types (including nil for backward compatibility)
[nil, REPO_TYPE_MODEL, REPO_TYPE_DATASET, REPO_TYPE_SPACE].freeze
- REPO_ID_SERIALIZATION_SEPARATOR =
Repository ID serialization separator (used for serialization of repo ids elsewhere)
"--"- SPACES_SDK_TYPES =
Space SDK types
["gradio", "streamlit", "docker", "static"].freeze
- REPO_TYPES_URL_PREFIXES =
Repository type URL prefixes
{ REPO_TYPE_DATASET => "datasets/", REPO_TYPE_SPACE => "spaces/" }.freeze
- REPO_TYPES_MAPPING =
Repository type mappings
{ "datasets" => REPO_TYPE_DATASET, "spaces" => REPO_TYPE_SPACE, "models" => REPO_TYPE_MODEL }.freeze
- HF_CACHE_SUBDIR =
Cache directory structure
"hub"- MODELS_CACHE_SUBDIR =
"models"- HEADER_X_REPO_COMMIT =
HTTP header names
"X-Repo-Commit"- HEADER_X_LINKED_SIZE =
"X-Linked-Size"- HEADER_X_LINKED_ETAG =
"X-Linked-Etag"- HEADER_X_BILL_TO =
"X-HF-Bill-To"- HEADER_X_XET_ENDPOINT =
"X-Xet-Cas-Url"- HEADER_X_XET_ACCESS_TOKEN =
"X-Xet-Access-Token"- HEADER_X_XET_EXPIRATION =
"X-Xet-Token-Expiration"- HEADER_X_XET_HASH =
"X-Xet-Hash"- HEADER_X_XET_REFRESH_ROUTE =
"X-Xet-Refresh-Route"- USER_AGENT =
User agent string for API requests
"huggingface_hub/#{VERSION}; ruby/#{RUBY_VERSION}"