Skip to content

Commit

Permalink
anthropic[patch]: update base_url of anthropic (langchain-ai#18634)
Browse files Browse the repository at this point in the history
A small change ~

- [ ] **update base_url**: "package: langchain_anthropic"

---------

Co-authored-by: yangenfeng <yangenfeng@xiaoniangao.com>
Co-authored-by: Harrison Chase <hw.chase.17@gmail.com>
  • Loading branch information
3 people authored and Dave Bechberger committed Mar 29, 2024
1 parent c6d1998 commit c436766
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions libs/partners/anthropic/langchain_anthropic/chat_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -201,11 +201,16 @@ def validate_environment(cls, values: Dict) -> Dict:
values.get("anthropic_api_key") or os.environ.get("ANTHROPIC_API_KEY") or ""
)
values["anthropic_api_key"] = anthropic_api_key
values["_client"] = anthropic.Client(
api_key=anthropic_api_key.get_secret_value()
api_key = anthropic_api_key.get_secret_value()
api_url = (
values.get("anthropic_api_url")
or os.environ.get("ANTHROPIC_API_URL")
or "https://api.anthropic.com"
)
values["anthropic_api_url"] = api_url
values["_client"] = anthropic.Client(api_key=api_key, base_url=api_url)
values["_async_client"] = anthropic.AsyncClient(
api_key=anthropic_api_key.get_secret_value()
api_key=api_key, base_url=api_url
)
return values

Expand Down

0 comments on commit c436766

Please sign in to comment.