Skip to content

Commit

Permalink
Fix the issue where ANTHROPIC_API_URL set in environment is not takin… (
Browse files Browse the repository at this point in the history
#6400)

I apologize for the error: the 'ANTHROPIC_API_URL' environment variable
doesn't take effect if the 'anthropic_api_url' parameter has a default
value.

#### Who can review?
  Models
  - @hwchase17
  - @agola11
  • Loading branch information
zengbo authored Jun 20, 2023
1 parent 9f5f747 commit 7e5f5eb
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions langchain/llms/anthropic.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class _AnthropicCommon(BaseModel):
default_request_timeout: Optional[Union[float, Tuple[float, float]]] = None
"""Timeout for requests to Anthropic Completion API. Default is 600 seconds."""

anthropic_api_url: str = "https://api.anthropic.com"
anthropic_api_url: Optional[str] = None

anthropic_api_key: Optional[str] = None

Expand All @@ -52,7 +52,10 @@ def validate_environment(cls, values: Dict) -> Dict:
)
"""Get custom api url from environment."""
anthropic_api_url = get_from_dict_or_env(
values, "anthropic_api_url", "ANTHROPIC_API_URL"
values,
"anthropic_api_url",
"ANTHROPIC_API_URL",
default="https://api.anthropic.com",
)

try:
Expand Down

0 comments on commit 7e5f5eb

Please sign in to comment.