gen_ai_hub.proxy.native.google_genai.clients module¶
- class gen_ai_hub.proxy.native.google_genai.clients.AICoreDynamicTransport(proxy_client: BaseProxyClient, **deployment_selector_kwargs)¶
Bases:
BaseTransportSynchronous transport that dynamically resolves deployment URLs per request.
- __init__(proxy_client: BaseProxyClient, **deployment_selector_kwargs)¶
Transport constructor.
- Parameters:
proxy_client (BaseProxyClient) – The proxy client used to select deployments.
- get_selector_kwargs()¶
Get the deployment selector kwargs.
- Returns:
The deployment selector kwargs.
- Return type:
dict
- handle_request(request: Request) Response¶
Handles the request by rewriting it to route through the appropriate AI Core deployment.
- Parameters:
request (httpx.Request) – The original HTTPX request.
- Returns:
The HTTPX response from the AI Core deployment.
- Return type:
httpx.Response
- close()¶
Closes the inner transport.
- class gen_ai_hub.proxy.native.google_genai.clients.AsyncAICoreDynamicTransport(proxy_client: BaseProxyClient, **deployment_selector_kwargs)¶
Bases:
AsyncBaseTransportAsynchronous transport that dynamically resolves deployment URLs per request.
- __init__(proxy_client: BaseProxyClient, **deployment_selector_kwargs)¶
Transport constructor.
- Parameters:
proxy_client (BaseProxyClient) – The proxy client used to select deployments.
- get_selector_kwargs()¶
get the deployment selector kwargs.
- Returns:
The deployment selector kwargs.
- Return type:
dict
- async handle_async_request(request: Request) Response¶
Handles the request by rewriting it to route through the appropriate AI Core deployment.
- Parameters:
request (httpx.Request) – The original HTTPX request.
- Returns:
The HTTPX response from the AI Core deployment.
- Return type:
httpx.Response
- async aclose()¶
Closes the inner transport.
- class gen_ai_hub.proxy.native.google_genai.clients.Models(api_client_: BaseApiClient)¶
Bases:
ModelsClass that extends the original Google Models class for patch embed_content method.
- embed_content(*, model: str, contents: Content | str | Image | File | Part | list[str | Image | File | Part] | list[Content | str | Image | File | Part | list[str | Image | File | Part]] | ContentDict | FileDict | PartDict | list[str | Image | File | FileDict | Part | PartDict] | list[Content | ContentDict | str | Image | File | FileDict | Part | PartDict | list[str | Image | File | FileDict | Part | PartDict]], config: EmbedContentConfig | EmbedContentConfigDict | None = None) EmbedContentResponse¶
Need for add model version for “gemini-embedding” model.
- class gen_ai_hub.proxy.native.google_genai.clients.Client(vertexai: bool = True, project: str = 'placeholder', location: str = 'placeholder', deployment_id: str = '', config_id: str = '', config_name: str = '', proxy_client: BaseProxyClient = None, timeout: int = None, **kwargs)¶
Bases:
ClientUnified, native-feeling client that dynamically routes requests through SAP AI Core deployments based on the requested identifiers e.g. model name.
- __init__(vertexai: bool = True, project: str = 'placeholder', location: str = 'placeholder', deployment_id: str = '', config_id: str = '', config_name: str = '', proxy_client: BaseProxyClient = None, timeout: int = None, **kwargs)¶
Initializes the Client.
- Parameters:
vertexai (bool, optional) – to indicate Vertex AI usage, defaults to True
project (str, optional) – the GCP project, defaults to “placeholder”
location (str, optional) – the GCP location, defaults to “placeholder”
deployment_id (str, optional) – the deployment identifier, defaults to “”
config_id (str, optional) – the configuration identifier, defaults to “”
config_name (str, optional) – the configuration name, defaults to “”
proxy_client (BaseProxyClient, optional) – the proxy client to use, defaults to None
timeout (int, optional) – the request timeout, defaults to None