Skip to content

Commit

Permalink
Skips creating boto client for Bedrock if passed in constructor (lang…
Browse files Browse the repository at this point in the history
…chain-ai#5523)

# Skips creating boto client if passed in constructor
Current LLM and Embeddings class always creates a new boto client, even
if one is passed in a constructor. This blocks certain users from
passing in externally created boto clients, for example in SSO
authentication.

## Who can review?
@hwchase17 
@jasondotparse 
@rsgrewal-aws

<!-- For a quicker response, figure out the right person to tag with @

  @hwchase17 - project lead

  Tracing / Callbacks
  - @agola11

  Async
  - @agola11

  DataLoaders
  - @eyurtsev

  Models
  - @hwchase17
  - @agola11

  Agents / Tools / Toolkits
  - @vowelparrot

  VectorStores / Retrievers / Memory
  - @dev2049

 -->
  • Loading branch information
3coins authored and Undertone0809 committed Jun 19, 2023
1 parent 5a4c2d7 commit d227c5d
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
4 changes: 4 additions & 0 deletions langchain/embeddings/bedrock.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,10 @@ class Config:
@root_validator()
def validate_environment(cls, values: Dict) -> Dict:
"""Validate that AWS credentials to and python package exists in environment."""

if "client" in values:
return values

try:
import boto3

Expand Down
5 changes: 5 additions & 0 deletions langchain/llms/bedrock.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,11 @@ class Config:
@root_validator()
def validate_environment(cls, values: Dict) -> Dict:
"""Validate that AWS credentials to and python package exists in environment."""

# Skip creating new client if passed in constructor
if "client" in values:
return values

try:
import boto3

Expand Down

0 comments on commit d227c5d

Please sign in to comment.