gen_ai_hub.proxy.langchain.init_models module

gen_ai_hub.proxy.langchain.init_models.default_f_select_deployment(proxy_client: BaseProxyClient, **model_identification_kwargs: Dict[str, str]) BaseDeployment

Default function to select a deployment based on model identification kwargs.

Parameters:

proxy_client (BaseProxyClient) – The proxy client to use for selecting the deployment

Returns:

The selected deployment

Return type:

BaseDeployment

gen_ai_hub.proxy.langchain.init_models.handle_model_args_kwargs(proxy_client, args: List[Any], kwargs: Dict[str, Any])

Handles model identification arguments and keyword arguments.

Parameters:
  • proxy_client (_type_) – the proxy client to use for model identification

  • args (List[Any]) – list of positional arguments

  • kwargs (Dict[str, Any]) – dictionary of keyword arguments

Raises:

ValueError – if no model identification argument is provided

Returns:

A tuple containing the model name, model identification kwargs, and remaining kwargs

Return type:

Tuple[str, Dict[str, str], Dict[str, Any]]

class gen_ai_hub.proxy.langchain.init_models.ModelType(*values)

Bases: Enum

LLM = 1
EMBEDDINGS = 2
gen_ai_hub.proxy.langchain.init_models.init_llm(*args, proxy_client: BaseProxyClient | None = None, temperature: float = 0.0, max_tokens: int = 256, top_k: int | None = None, top_p: float = 1.0, init_func: Callable | None = None, model_id: str | None = '', **kwargs) BaseLanguageModel

Initializes a language model using the specified parameters.

Parameters:
  • proxy_client (ProxyClient) – The proxy client to use for the model (optional)

  • temperature (float) – The temperature parameter for model generation (default: 0.0)

  • max_tokens (int) – The maximum number of tokens to generate (default: 256)

  • top_k (int) – The top-k parameter for model generation (optional)

  • top_p (float) – The top-p parameter for model generation (default: 1.0)

  • init_func (Callable) – Function to call for initializing the model, optional

  • model_id (str) – id of the Amazon Bedrock model, needed in case a custom Amazon Bedrock model is being initiated (optional)

Returns:

The initialized language model

Return type:

BaseLanguageModel

gen_ai_hub.proxy.langchain.init_models.init_embedding_model(*args, proxy_client: BaseProxyClient | None = None, init_func: Callable | None = None, model_id: str | None = '', **kwargs) Embeddings

Initializes an embedding model using the specified parameters.

Parameters:
  • proxy_client (BaseProxyClient) – The proxy client to use for the model (optional)

  • init_func (Callable) – Function to call for initializing the model, optional

  • model_id (str) – id of the Amazon Bedrock model, needed in case a custom Amazon Bedrock model is being initiated (optional)

Returns:

The initialized embedding model

Return type:

Embeddings