MCPcopy Create free account
hub / github.com/AlayaLab/Hive / http_user_agent

Function http_user_agent

models/flowsep/diffusers/utils/hub_utils.py:68–89  ·  view source on GitHub ↗

Formats a user-agent string with basic info about a request.

(user_agent: Union[Dict, str, None] = None)

Source from the content-addressed store, hash-verified

66
67
68def http_user_agent(user_agent: Union[Dict, str, None] = None) -> str:
69 """
70 Formats a user-agent string with basic info about a request.
71 """
72 ua = f"diffusers/{__version__}; python/{sys.version.split()[0]}; session_id/{SESSION_ID}"
73 if DISABLE_TELEMETRY or HF_HUB_OFFLINE:
74 return ua + "; telemetry/off"
75 if is_torch_available():
76 ua += f"; torch/{_torch_version}"
77 if is_flax_available():
78 ua += f"; jax/{_jax_version}"
79 ua += f"; flax/{_flax_version}"
80 if is_onnx_available():
81 ua += f"; onnxruntime/{_onnxruntime_version}"
82 # CI will set this value to True
83 if os.environ.get("DIFFUSERS_IS_CI", "").upper() in ENV_VARS_TRUE_VALUES:
84 ua += "; is_ci/true"
85 if isinstance(user_agent, dict):
86 ua += "; " + "; ".join(f"{k}/{v}" for k, v in user_agent.items())
87 elif isinstance(user_agent, str):
88 ua += "; " + user_agent
89 return ua
90
91
92def get_full_repo_name(model_id: str, organization: Optional[str] = None, token: Optional[str] = None):

Callers 2

load_configMethod · 0.85
from_pretrainedMethod · 0.85

Calls 4

is_torch_availableFunction · 0.85
is_flax_availableFunction · 0.85
is_onnx_availableFunction · 0.85
getMethod · 0.80

Tested by

no test coverage detected