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

 
Modules
       
inspect
os
threading
uuid

 
Classes
       
builtins.object
ProxyClients

 
class ProxyClients(builtins.object)
    ProxyClients() -> 'None'
 
Catalog for proxy client classes.
 
  Methods defined here:
__init__(self) -> 'None'
Initializes a ProxyClients instance.
get_proxy_cls(self, proxy_version: 'str | None' = None) -> 'type[BaseProxyClient]'
Get the proxy client class for the given version.
 
:param proxy_version: The proxy version.
:type proxy_version: str | None, optional
:return: The proxy client class.
:rtype: type[BaseProxyClient]
get_proxy_cls_name(self, proxy_client_cls: 'type[BaseProxyClient] | BaseProxyClient') -> 'str'
Get the name of the proxy client class.
 
:param proxy_client_cls: The proxy client class or instance.
:type proxy_client_cls: type[BaseProxyClient] | BaseProxyClient
:raises ValueError: If the provided class is not a subclass of BaseProxyClient.
:raises KeyError: If the class is not registered.
:return: The name of the proxy client class.
:rtype: str
register(self, name: 'str')
Decorator to register a proxy client class.
 
:param name: The name to register the proxy client class under.
:type name: str
:raises ValueError: If the provided class is not a subclass of BaseProxyClient.
:return: A wrapper function.
:rtype: Callable

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

 
Functions
       
get_proxy_client(proxy_version: 'str | None' = None, catalog: 'Optional[ProxyClients]' = None, **kwargs) -> 'BaseProxyClient'
Get a proxy client for the given proxy version.
 
:param proxy_version: The version of the proxy client to retrieve. If not provided, the function will
                      attempt to retrieve the version using the `get_proxy_version` function.
:type proxy_version: str | None, optional
:param catalog: The catalog from which to retrieve the proxy client. If not provided, the function will 
                default to the `proxy_clients` catalog
:type catalog: Optional[ProxyClients], optional
:param kwargs: Arbitrary keyword arguments that will be passed to the constructor of the proxy client class.
:type kwargs: dict
:return: An instance of the proxy client.
:rtype: BaseProxyClient
get_proxy_version(catalog: 'Optional[ProxyClients]' = None) -> 'str'
Get the current proxy version. The version is selected in the following order:
 
- thread-local overwrite (set with proxy_version_context)
 
- global overwrite (set with set_proxy_version)
 
- environment variable (LLM_PROXY_VERSION)
 
- first registered proxy version
 
:param catalog: The catalog from which to get the proxy version. If none is provided,
:type catalog: Optional[ProxyClients], optional
:raises ValueError: If no proxy version is set.
:return: The current proxy version.
:rtype: str
proxy_version_context(proxy_version: 'str', catalog: 'Optional[ProxyClients]' = None) -> 'None'
Context manager to set a thread-local proxy version.
 
:param proxy_version: The proxy version to set.
:type proxy_version: str
:param catalog: The catalog for which the proxy version is to be set. If none is provided,
                the proxy version is set for the default proxy_clients catalog.
:type catalog: Optional[ProxyClients], optional
:raises ValueError: If proxy_version is not a string.
set_proxy_version(proxy_version: 'str', catalog: 'Optional[ProxyClients]' = None) -> 'None'
Set the global proxy version.
 
:param proxy_version: The proxy version to set.
:type proxy_version: str
:param catalog: The catalog for which the proxy version is to be set. If none is provided,
                the proxy version is set for the default proxy_clients catalog.
:type catalog: Optional[ProxyClients], optional
:raises ValueError: If proxy_version is not a string.

 
Data
        Optional = typing.Optional
PROXY_VERSION_ENV_VARIABLE = 'LLM_PROXY_VERSION'
THREAD_PROXY_VERSION_OVERWRITE = 'proxy_version_overwrite'
annotations = _Feature((3, 7, 0, 'beta', 1), (3, 11, 0, 'alpha', 0), 16777216)
no_value = <object object>
proxy_clients = <gen_ai_hub.proxy.core.proxy_clients.ProxyClients object>