From 7e5f5ebf86ac1d72d216443d38ceb127e3de27c9 Mon Sep 17 00:00:00 2001 From: zengbo Date: Tue, 20 Jun 2023 13:20:36 +0800 Subject: [PATCH] =?UTF-8?q?Fix=20the=20issue=20where=20ANTHROPIC=5FAPI=5FU?= =?UTF-8?q?RL=20set=20in=20environment=20is=20not=20takin=E2=80=A6=20(#640?= =?UTF-8?q?0)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 --- langchain/llms/anthropic.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/langchain/llms/anthropic.py b/langchain/llms/anthropic.py index ec47b755b3..3c4bcf69b6 100644 --- a/langchain/llms/anthropic.py +++ b/langchain/llms/anthropic.py @@ -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 @@ -52,7 +52,10 @@ class _AnthropicCommon(BaseModel): ) """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: