gen_ai_hub.proxy.core.utils
index
/home/jenkins/agent/workspace/ation_generative-ai-hub-sdk_main/gen_ai_hub/proxy/core/utils.py

 
Modules
       
time
warnings

 
Functions
       
if_set(value, alternative=NOT_GIVEN)
Check if a value is set (not NotGiven and not None), otherwise return an alternative.
 
:param value: the value to check.
:type value: any
:param alternative: the alternative value to return if the original value is not set.
:type alternative: any
:return: The original value if set, otherwise the alternative.
:rtype: any
if_str_set(value: 'str', alternative: 'str' = '')
Check if a string value is set (not empty), otherwise return an alternative.
 
:param value: the string value to check.
:type value: str
:param alternative: the alternative string to return if the original value is empty.
:type alternative: str, optional
:return: The original string if not empty, otherwise the alternative.
:rtype: str
kwargs_if_set(**kwargs)
Filter keyword arguments to include only those that are set (not NotGiven and not None).
 
:return: A dictionary of keyword arguments that are set.
:rtype: Dict[str, any]
lru_cache_extended(timeout: 'Optional[int]' = None, maxsize: 'Optional[int]' = None, typed: 'bool' = False, first_arg_self: 'bool' = False)
Decorator to add LRU caching with optional timeout to methods. 
Handles 'self' as a weak reference for instance methods if required.
 
:param timeout: time in seconds after which the cache will be refreshed. If None, never expires.
:type timeout: Optional[int], optional
:param maxsize: maximum size of the cache.
:type maxsize: Optional[int], optional
:param typed: if True, arguments of different types will be cached separately.
:type typed: bool, optional
:param first_arg_self: if True, treats the first argument as 'self' and uses its id for caching.
:type first_arg_self: bool, optional
:return: Decorated method with cache and optional timeout.
:rtype: Callable
warn_once(msg, category=None)
Issue a warning only once for a given message.
 
:param msg: the warning message.
:type msg: str
:param category: the warning category.
:type category: Optional[Warning], optional

 
Data
        Any = typing.Any
Dict = typing.Dict
List = typing.List
Literal = typing.Literal
NOT_GIVEN = NOT_GIVEN
Optional = typing.Optional
Tuple = typing.Tuple
annotations = _Feature((3, 7, 0, 'beta', 1), (3, 11, 0, 'alpha', 0), 16777216)