MCPcopy Create free account
hub / github.com/YesianRohn/TextSSR / http_user_agent

Function http_user_agent

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

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