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

 
Classes
       
builtins.object
NotGiven
Omit
PredictionURLs

 
class NotGiven(builtins.object)
     Methods defined here:
__bool__(self) -> 'Literal[False]'

Data descriptors defined here:
__dict__
dictionary for instance variables (if defined)
__weakref__
list of weak references to the object (if defined)

 
class Omit(builtins.object)
     Methods defined here:
__bool__(self) -> 'Literal[False]'

Data descriptors defined here:
__dict__
dictionary for instance variables (if defined)
__weakref__
list of weak references to the object (if defined)

 
class PredictionURLs(builtins.object)
    PredictionURLs(suffixes: 'Optional[Dict[str, str]]' = None) -> 'None'
 
A class to manage prediction URLs with dynamic suffixes for different models.
 
Args:
    suffixes (Optional[Dict[str, str]]): A dictionary mapping model names to their URL suffixes.
 
  Methods defined here:
__call__(self, model_name: 'str', url: 'str', fixed_suffix: 'Optional[str]' = None) -> 'str'
Generate a complete URL for a given model.
 
Args:
    model_name (str): The name of the model.
    url (str): The base URL.
    fixed_suffix (Optional[str]): A fixed suffix to override the registered one.
 
Returns:
    str or None: The complete URL for the model. None means there is no suffix registered for the model and usally the url should be used.
 
Raises:
    KeyError: If the model name is not registered.
__init__(self, suffixes: 'Optional[Dict[str, str]]' = None) -> 'None'
Initialize self.  See help(type(self)) for accurate signature.
register(self, suffixes: 'Dict[str, str | Omit]') -> 'None'
Register new model suffixes.
 
Args:
    suffixes (Dict[str, str]): A dictionary of model names and their corresponding URL suffixes.

Data descriptors defined here:
__dict__
dictionary for instance variables (if defined)
__weakref__
list of weak references to the object (if defined)

 
Functions
       
if_set(value, alternative=<gen_ai_hub.proxy.core.utils.NotGiven object at 0x7fdbcd17f2e0>)
kwargs_if_set(**kwargs)
lru_cache_extended(timeout: 'Optional[int]' = None, maxsize: 'Optional[int]' = None, typed: 'bool' = False, first_arg_self: 'bool' = False)
A decorator that adds LRU caching with an optional timeout to methods.
Handles 'self' as a weak reference for instance methods if required.
 
Args:
    timeout: Time in seconds after which the cache will be refreshed. If None, never expires.
    maxsize: Maximum size of the cache.
    typed: If True, arguments of different types will be cached separately.
    first_arg_self: If True, treats the first argument as 'self' and uses its id for caching.
 
Returns:
    Callable: Decorated method with cache and optional timeout.

 
Data
        Any = typing.Any
Dict = typing.Dict
List = typing.List
Literal = typing.Literal
NOT_GIVEN = <gen_ai_hub.proxy.core.utils.NotGiven object>
OMIT = <gen_ai_hub.proxy.core.utils.Omit object>
Optional = typing.Optional
Tuple = typing.Tuple
annotations = _Feature((3, 7, 0, 'beta', 1), (3, 11, 0, 'alpha', 0), 16777216)