gen_ai_hub.proxy package
- class GenAIHubProxyClient
Bases:
BaseProxyClientGenAIHubProxyClient is a proxy client for interacting with the GenAI Hub.
- classmethod add_foundation_model_scenario(scenario_id, config_names=None, prediction_url_suffix=None, model_name_parameter='model_name')
Add a foundational model scenario to the client.
- Parameters:
scenario_id (str) -- the scenario ID.
config_names (Optional[List[str]], optional) -- list of configuration names, defaults to None
prediction_url_suffix (Optional[str], optional) -- prediction URL suffix, defaults to None
model_name_parameter (str, optional) -- model name parameter, defaults to 'model_name'
- classmethod for_profile(profile=None)
Create a GenAIHubProxyClient instance for the given profile.
- Parameters:
profile (str, optional) -- Profile name, defaults to None
- Returns:
GenAIHubProxyClient instance.
- Return type:
- classmethod init_client(data)
Initialize the client with the provided data.
- Parameters:
data (Any) -- Input data for client initialization.
- Returns:
Initialized data.
- Return type:
Any
- classmethod set_default_values(**kwargs)
Set default values for the client.
- get_additional_headers()
Get only the additional headers (instance-level and request-level).
- Returns:
Additional headers.
- Return type:
Dict[str, str]
- get_ai_core_token()
Get the AI core token for authentication.
- Returns:
AI core token.
- Return type:
str
- get_deployments()
Get the list of deployments.
- Returns:
List of deployments.
- Return type:
List[Deployment]
- get_request_header()
Get the request headers for requests made by the client.
- Returns:
Request headers.
- Return type:
Dict[str, str]
- model_post_init(context, /)
This function is meant to behave like a BaseModel method to initialise private attributes.
It takes context as an argument since that's what pydantic-core passes when calling it.
- Args:
self: The BaseModel instance. context: The context.
- Parameters:
self (BaseModel)
context (Any)
- Return type:
None
- select_deployment(raise_on_multiple=False, **search_key_value)
- Parameters:
raise_on_multiple (bool)
- set_headers_addition(headers)
Set additional headers for requests made by the client.
- Parameters:
headers (Dict[str, str]) -- Headers to add.
- update_deployments()
Update the list of deployments from the GenAI Hub.
- Returns:
List of updated deployments.
- Return type:
List[Deployment]
- AI_CLIENT_TYPE_VAL: ClassVar[str] = 'GenAI Hub SDK (Python)'
- ai_core_client: AICoreV2Client | None
- auth_url: str | None
- base_url: str | None
- client_id: str | None
- client_secret: str | None
- default_values: ClassVar[Dict[str, Any]] = {}
- property deployment_class: Type[Deployment]
- property deployments: List[Deployment]
- foundational_model_scenarios: ClassVar[List[FoundationalModelScenario]] = [FoundationalModelScenario(scenario_id='foundation-models', config_names=['*'], model_name_parameter='model_name', prediction_url_suffix=None)]
- model_config: ClassVar[ConfigDict] = {'arbitrary_types_allowed': True, 'extra': 'allow', 'protected_namespaces': ()}
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- on_invalid_deployments: ClassVar[InvalidDeploymentBehavior] = 'warn'
- property request_header: Dict[str, Any]
- resource_group: str | None
- get_proxy_client(proxy_version=None, catalog=None, **kwargs)
Get a proxy client for the given proxy version.
- Parameters:
proxy_version (str | None, optional) -- 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.
catalog (Optional[ProxyClients], optional) -- The catalog from which to retrieve the proxy client. If not provided, the function will default to the proxy_clients catalog
kwargs (dict) -- Arbitrary keyword arguments that will be passed to the constructor of the proxy client class.
- Returns:
An instance of the proxy client.
- Return type:
- get_proxy_version(catalog=None)
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
- Parameters:
catalog (Optional[ProxyClients], optional) -- The catalog from which to get the proxy version. If none is provided,
- Raises:
ValueError -- If no proxy version is set.
- Returns:
The current proxy version.
- Return type:
str
- set_proxy_version(proxy_version, catalog=None)
Set the global proxy version.
- Parameters:
proxy_version (str) -- The proxy version to set.
catalog (Optional[ProxyClients], optional) -- 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.
- Raises:
ValueError -- If proxy_version is not a string.
- Return type:
None