MCPcopy
hub / github.com/huggingface/diffusers / http_user_agent

Function http_user_agent

src/diffusers/utils/hub_utils.py:74–95  ·  view source on GitHub ↗

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

(user_agent: dict | str | None = None)

Source from the content-addressed store, hash-verified

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

Callers 2

load_configMethod · 0.85
from_pretrainedMethod · 0.85

Calls 5

is_torch_availableFunction · 0.85
is_flax_availableFunction · 0.85
is_onnx_availableFunction · 0.85
splitMethod · 0.80
getMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…