Skip to content

Commit

Permalink
cleanup api_key param handling
Browse files Browse the repository at this point in the history
  • Loading branch information
mattf committed Sep 16, 2024
1 parent c546bc4 commit cb117ce
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions libs/ai-endpoints/langchain_nvidia_ai_endpoints/_common.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,12 +115,12 @@ def _validate_base_url(cls, v: str) -> str:

@root_validator(pre=True)
def _preprocess_args(cls, values: Dict[str, Any]) -> Dict[str, Any]:
values["api_key"] = (
values.get(cls._api_key_var.lower())
or values.get("api_key")
or os.getenv(cls._api_key_var)
or None
)
# if api_key is not provided or None,
# try to get it from the environment
# we can't use Field(default_factory=...)
# because construction may happen with api_key=None
if values.get("api_key") is None:
values["api_key"] = os.getenv(cls._api_key_var)

## Making sure /v1 in added to the url, followed by infer_path
if "base_url" in values:
Expand Down

0 comments on commit cb117ce

Please sign in to comment.