Skip to content

fix: migrate llm.py from langchain.llms.bedrock to langchain_aws#166

Closed
Sagargupta16 wants to merge 1 commit intoaws-samples:mainfrom
Sagargupta16:fix/migrate-llm-to-langchain-aws
Closed

fix: migrate llm.py from langchain.llms.bedrock to langchain_aws#166
Sagargupta16 wants to merge 1 commit intoaws-samples:mainfrom
Sagargupta16:fix/migrate-llm-to-langchain-aws

Conversation

@Sagargupta16
Copy link
Copy Markdown

Description

Migrates the Bedrock integration in llm.py from the removed langchain.llms.bedrock module to langchain_aws, as outlined in #165.

Changes

src/workspaces/cookiefactoryv3/assistant/app/lib/llm.py:

  • from langchain.llms.bedrock import Bedrock -> from langchain_aws import BedrockLLM
  • from langchain.embeddings.bedrock import BedrockEmbeddings -> from langchain_aws import BedrockEmbeddings
  • Bedrock() constructor calls -> BedrockLLM()

src/workspaces/cookiefactoryv3/assistant/requirements.txt:

  • langchain==0.0.252 -> langchain>=0.2.0
  • Added langchain-aws>=0.2.0

Context

The langchain.llms.bedrock module was removed in langchain v0.2 as a breaking change. The langchain-aws package is the official replacement per the migration guide.

This is the follow-up to PR #164, which migrated chainlit and langchain-classic but held llm.py Bedrock integration out of scope.

Note

Model IDs (anthropic.claude-instant-v1, anthropic.claude-v2) and their kwargs are kept as-is in this PR. Updating to Claude 3 model IDs can be done as a separate follow-up.

Closes #165

- Replace `from langchain.llms.bedrock import Bedrock` with
  `from langchain_aws import BedrockLLM`
- Replace `from langchain.embeddings.bedrock import BedrockEmbeddings` with
  `from langchain_aws import BedrockEmbeddings`
- Replace `Bedrock()` calls with `BedrockLLM()`
- Update requirements.txt: langchain>=0.2.0, add langchain-aws>=0.2.0

The `langchain.llms.bedrock` module was removed in langchain v0.2.
Migration follows the official langchain-aws guide:
https://python.langchain.com/docs/integrations/platforms/aws/

Closes #165
@Sagargupta16
Copy link
Copy Markdown
Author

Closing -- repo appears inactive (last merge Jul 2023). Thanks for the project!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix: migrate llm.py from langchain.llms.bedrock to langchain_aws

1 participant