| | |
- if_set(value, alternative=<gen_ai_hub.proxy.core.utils.NotGiven object at 0x7f403f71e770>)
- 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
|