MCPcopy Create free account
hub / github.com/modelscope/modelscope / get_user_agent

Method get_user_agent

modelscope/hub/api.py:415–434  ·  view source on GitHub ↗

Build a user-agent string carrying SDK version and telemetry.

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

Source from the content-addressed store, hash-verified

413
414 @staticmethod
415 def get_user_agent(user_agent: Union[Dict, str, None] = None) -> str:
416 """Build a user-agent string carrying SDK version and telemetry."""
417 env = os.environ.get(MODELSCOPE_CLOUD_ENVIRONMENT, 'custom')
418 user_name = os.environ.get(MODELSCOPE_CLOUD_USERNAME, 'unknown')
419
420 from modelscope import __version__
421 ua = (
422 f'modelscope/{__version__}; '
423 f'python/{platform.python_version()}; '
424 f'session_id/{ModelScopeConfig.get_user_session_id()}; '
425 f'platform/{platform.platform()}; '
426 f'processor/{platform.processor()}; '
427 f'env/{env}; '
428 f'user/{user_name}'
429 )
430 if isinstance(user_agent, dict):
431 ua += '; ' + '; '.join(f'{k}/{v}' for k, v in user_agent.items())
432 elif isinstance(user_agent, str):
433 ua += '; ' + user_agent
434 return ua

Callers 3

__init__Method · 0.80
__init__Method · 0.80

Calls 4

get_user_session_idMethod · 0.80
getMethod · 0.45
processorMethod · 0.45
itemsMethod · 0.45

Tested by

no test coverage detected