MCPcopy Create free account
hub / github.com/TencentARC/BrushNet / http_user_agent

Function http_user_agent

src/diffusers/utils/hub_utils.py:72–93  ·  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

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

Callers 2

load_configMethod · 0.85
from_pretrainedMethod · 0.85

Calls 3

is_torch_availableFunction · 0.85
is_flax_availableFunction · 0.85
is_onnx_availableFunction · 0.85

Tested by

no test coverage detected