gen_ai_hub package

class GenAIHubProxyClient

Bases: BaseProxyClient

GenAIHubProxyClient 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:

GenAIHubProxyClient

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

Subpackages