Skip to content

Commit

Permalink
document proxies and trust_env parameters
Browse files Browse the repository at this point in the history
  • Loading branch information
Wauplin committed Aug 13, 2024
1 parent 15ba44a commit cd47edb
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/huggingface_hub/inference/_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,8 @@ class InferenceClient:
Values in this dictionary will override the default values.
cookies (`Dict[str, str]`, `optional`):
Additional cookies to send to the server.
proxies (`Any`, `optional`):
Proxies to use for the request.
base_url (`str`, `optional`):
Base URL to run inference. This is a duplicated argument from `model` to make [`InferenceClient`]
follow the same pattern as `openai.OpenAI` client. Cannot be used if `model` is set. Defaults to None.
Expand Down
4 changes: 4 additions & 0 deletions src/huggingface_hub/inference/_generated/_async_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,10 @@ class AsyncInferenceClient:
Values in this dictionary will override the default values.
cookies (`Dict[str, str]`, `optional`):
Additional cookies to send to the server.
trust_env ('bool', 'optional'):
Trust environment settings for proxy configuration if the parameter is `True` (`False` by default).
proxies (`Any`, `optional`):
Proxies to use for the request.
base_url (`str`, `optional`):
Base URL to run inference. This is a duplicated argument from `model` to make [`InferenceClient`]
follow the same pattern as `openai.OpenAI` client. Cannot be used if `model` is set. Defaults to None.
Expand Down
9 changes: 9 additions & 0 deletions utils/generate_async_inference_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -481,6 +481,15 @@ def _add_get_client_session(code: str) -> str:
code = _add_before(code, "proxies: Optional[Any] = None,", "trust_env: bool = False,")
code = _add_before(code, "\n self.proxies = proxies\n", "\n self.trust_env = trust_env")

# Document `trust_env` parameter
code = _add_before(
code,
"\n proxies (`Any`, `optional`):",
"""
trust_env ('bool', 'optional'):
Trust environment settings for proxy configuration if the parameter is `True` (`False` by default).""",
)

# insert `_get_client_session` before `_resolve_url` method
client_session_code = """
Expand Down

0 comments on commit cd47edb

Please sign in to comment.