langchain-ai / langchain-aws

Build LangChain Applications on AWS
MIT License
97 stars 71 forks source link

Adding config argument for BedrockEmbeddings #102

Closed ravediamond closed 2 months ago

ravediamond commented 3 months ago

Description

This pull request enhances the functionality of the BedrockEmbeddings class by adding an optional config argument as a botocore.config.Config to give more possible configuration for the boto3 client, in the same way as how it is done on the class ChatBedrock.

Here an example answer before the change:

embedding = BedrockEmbeddings(
    model_id="MODEL_ID",
    region_name="REGION_NAME",
    profile="PROFILE",
)

And now after the change:

config = BotocoreConfig(
    read_timeout=1000,
    retries=1,
)
embedding = BedrockEmbeddings(
    model_id="MODEL_ID",
    region_name="REGION_NAME",
    profile="PROFILE",
    config=config
)

Change

Motivation

This change will allow user to configure BedrockEmbeddings the same way as ChatBedrock.

Additional Notes

This change maintains backwards compatibility with existing usage.

ravediamond commented 3 months ago

@3coins can you please have a look? I confirmed that this PR is working. Thanks in advance.