Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding support for amazon personalize Integration #13216

Closed
wants to merge 4 commits into from

Conversation

pranava-amzn
Copy link
Contributor

@pranava-amzn pranava-amzn commented Nov 10, 2023

Amazon Personalize support on Langchain

This PR introduces an integration with Amazon Personalize to help you to retrieve recommendations and use them in your natural language applications. This integration provides two new components:

  1. An AmazonPersonalize client, that provides a wrapper around the Amazon Personalize API.
  2. An AmazonPersonalizeChain, that provides a chain to pull in recommendations using the client, and then generating the response in natural language.

Here is some sample code to explain the usage.

from langchain.utilities import AmazonPersonalize
from langchain.chains import AmazonPersonalizeChain
from langchain.llms.bedrock import Bedrock

recommender_arn = "<insert_arn>"

client=AmazonPersonalize(
    credentials_profile_name="default",
    region_name="us-west-2",
    recommender_arn=recommender_arn
)
bedrock_llm = Bedrock(
    model_id="anthropic.claude-v2", 
    region_name="us-west-2"
)

chain = AmazonPersonalizeChain.from_llm(
    llm=bedrock_llm, 
    client=client
)
response = chain({'user_id': '1'})

Reviewer: @3coins

Copy link

vercel bot commented Nov 10, 2023

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
langchain ✅ Ready (Inspect) Visit Preview 💬 Add feedback Nov 10, 2023 7:05pm

@dosubot dosubot bot added Ɑ: models Related to LLMs or chat model modules 🤖:enhancement A large net-new component, integration, or chain. Use sparingly. The largest features 🔌: aws Primarily related to Amazon Web Services (AWS) integrations labels Nov 10, 2023
Copy link
Contributor

@3coins 3coins left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@pranava-amzn
Looks great! Thanks for adding this. 🚀

@3coins
Copy link
Contributor

3coins commented Nov 10, 2023

cc @baskaryan for help with merging this.

@3coins
Copy link
Contributor

3coins commented Nov 15, 2023

@baskaryan
Let me know if there is anything I can do to move this forward. Thanks!

@pranava-amzn
Copy link
Contributor Author

Hi @baskaryan, Need your help with this PR. Let me and @3coins know. Thanks!

@pranava-amzn
Copy link
Contributor Author

pranava-amzn commented Nov 21, 2023

Hi @baskaryan , gentle reminder on this PR. Could you take a look pls and provide your feedback?

Copy link
Contributor

@hwchase17 hwchase17 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i think adding this is a whole new use case is a bit extreme. i would probably suggest a cookbook

other than that, looks good

@pranava-amzn
Copy link
Contributor Author

i think adding this is a whole new use case is a bit extreme. i would probably suggest a cookbook

other than that, looks good

@hwchase17 Thanks for reviewing. I'll move the docs to cookbook and update the PR in a bit. Appreciate your inputs on this :)

@3coins
Copy link
Contributor

3coins commented Dec 5, 2023

@hwchase17
Correct me if I am wrong, but are you suggesting to moving the complete code to the cookbook? Although, this use case hasn't been explored before, there are parallels in other providers that might warrant a new module for this. Here is a similar service that GCP provides.
https://cloud.google.com/recommendations

@hwchase17 hwchase17 closed this Jan 30, 2024
@baskaryan baskaryan reopened this Jan 30, 2024
baskaryan pushed a commit that referenced this pull request Feb 19, 2024
## Amazon Personalize support on Langchain

This PR is a successor to this PR -
#13216

This PR introduces an integration with [Amazon
Personalize](https://aws.amazon.com/personalize/) to help you to
retrieve recommendations and use them in your natural language
applications. This integration provides two new components:

1. An `AmazonPersonalize` client, that provides a wrapper around the
Amazon Personalize API.
2. An `AmazonPersonalizeChain`, that provides a chain to pull in
recommendations using the client, and then generating the response in
natural language.

We have added this to langchain_experimental since there was feedback
from the previous PR about having this support in experimental rather
than the core or community extensions.

Here is some sample code to explain the usage.

```python

from langchain_experimental.recommenders import AmazonPersonalize
from langchain_experimental.recommenders import AmazonPersonalizeChain
from langchain.llms.bedrock import Bedrock

recommender_arn = "<insert_arn>"

client=AmazonPersonalize(
    credentials_profile_name="default",
    region_name="us-west-2",
    recommender_arn=recommender_arn
)
bedrock_llm = Bedrock(
    model_id="anthropic.claude-v2", 
    region_name="us-west-2"
)

chain = AmazonPersonalizeChain.from_llm(
    llm=bedrock_llm, 
    client=client
)
response = chain({'user_id': '1'})
```


Reviewer: @3coins
haydeniw pushed a commit to haydeniw/langchain that referenced this pull request Feb 27, 2024
## Amazon Personalize support on Langchain

This PR is a successor to this PR -
langchain-ai#13216

This PR introduces an integration with [Amazon
Personalize](https://aws.amazon.com/personalize/) to help you to
retrieve recommendations and use them in your natural language
applications. This integration provides two new components:

1. An `AmazonPersonalize` client, that provides a wrapper around the
Amazon Personalize API.
2. An `AmazonPersonalizeChain`, that provides a chain to pull in
recommendations using the client, and then generating the response in
natural language.

We have added this to langchain_experimental since there was feedback
from the previous PR about having this support in experimental rather
than the core or community extensions.

Here is some sample code to explain the usage.

```python

from langchain_experimental.recommenders import AmazonPersonalize
from langchain_experimental.recommenders import AmazonPersonalizeChain
from langchain.llms.bedrock import Bedrock

recommender_arn = "<insert_arn>"

client=AmazonPersonalize(
    credentials_profile_name="default",
    region_name="us-west-2",
    recommender_arn=recommender_arn
)
bedrock_llm = Bedrock(
    model_id="anthropic.claude-v2", 
    region_name="us-west-2"
)

chain = AmazonPersonalizeChain.from_llm(
    llm=bedrock_llm, 
    client=client
)
response = chain({'user_id': '1'})
```


Reviewer: @3coins
@baskaryan
Copy link
Collaborator

landed in #17436

@baskaryan baskaryan closed this Apr 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🔌: aws Primarily related to Amazon Web Services (AWS) integrations 🤖:enhancement A large net-new component, integration, or chain. Use sparingly. The largest features Ɑ: models Related to LLMs or chat model modules
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants