nat.llm.utils.http_client#
Classes#
Return type for the |
Functions#
|
Create an httpx client with timeout and verify setting based on LLM configuration parameters. |
|
Context manager for a synchronous httpx client, to ensure that the client is properly closed after use. |
|
Async context manager for an asynchronous httpx client, to ensure that the client is properly closed after use. |
|
Get a dictionary of HTTP clients, one sync one async. |
|
Disable SSL verification for litellm if verify_ssl is set to False in the LLM configuration. |
Module Contents#
- _create_http_client(
- llm_config: nat.data_models.llm.LLMBaseConfig,
- use_async: bool = True,
- \*\*kwargs,
Create an httpx client with timeout and verify setting based on LLM configuration parameters.
- Args:
llm_config: LLM configuration object use_async: Whether to create an AsyncClient (True) or a regular Client (False). Defaults to True.
- Returns:
An httpx.AsyncClient or httpx.Client
- http_client(
- llm_config: nat.data_models.llm.LLMBaseConfig,
- \*\*kwargs,
Context manager for a synchronous httpx client, to ensure that the client is properly closed after use.
- async async_http_client(
- llm_config: nat.data_models.llm.LLMBaseConfig,
- \*\*kwargs,
Async context manager for an asynchronous httpx client, to ensure that the client is properly closed after use.
- class HttpClients#
Bases:
TypedDictReturn type for the
http_clientscontext manager.Initialize self. See help(type(self)) for accurate signature.
- http_client: httpx.Client#
- async_http_client: httpx.AsyncClient#
- async http_clients(
- llm_config: nat.data_models.llm.LLMBaseConfig,
- \*\*kwargs,
Get a dictionary of HTTP clients, one sync one async.
This is a wrapper around
async_http_clientandhttp_client, useful for LLMs that support both sync and async clients.
- _handle_litellm_verify_ssl(
- llm_config: nat.data_models.llm.LLMBaseConfig,
Disable SSL verification for litellm if verify_ssl is set to False in the LLM configuration.
Currently litellm does not support disabling this on a per-LLM basis for any backend other than Bedrock and AIM Guardrail, calling this function will set the global litellm.ssl_verify and impact all subsequent litellm calls.