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

Added support for stability API for bedrock #7364

Closed

Conversation

gauravrele87
Copy link

Summary

This PR adds support for stability AI in bedrock. Implementation is going to return the image in base64 format as text string.

@dosubot dosubot bot added the 🤖:improvement Medium size change to existing code to handle new use-cases label Jul 7, 2023
@vercel
Copy link

vercel bot commented Jul 7, 2023

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

1 Ignored Deployment
Name Status Preview Comments Updated (UTC)
langchain ⬜️ Ignored (Inspect) Jul 7, 2023 9:26pm

@baskaryan
Copy link
Collaborator

just let us know when it's ready for review @gauravrele87!

@gauravrele87 gauravrele87 marked this pull request as ready for review July 10, 2023 18:36
@gauravrele87
Copy link
Author

@baskaryan Its ready for review

@efriis
Copy link
Member

efriis commented Jul 10, 2023

Hey @gauravrele87 ! How do you hope to use this? I believe you're calling an image generation model and getting a base64-encoded image back, which doesn't fit our LLM (text-to-text) abstraction particularly well.

Would a tool that generates images from the bedrock-stability endpoint be better?

@3coins
Copy link
Contributor

3coins commented Jul 10, 2023

@efriis
Thanks for reviewing this PR. This implementation returns a base64 image as text output from the LLM class. We are expecting most users would want to write the image to filesystem for later access.

from base64 import b64decode
img = b64decode(base64_data)
with open('image.png', 'wb') as f:
    f.write(img)

Would a tool that generates images from the bedrock-stability endpoint be better?

Most tools I see so far are generating text output. Is there an example of a similar tool that generates non-text output? I am also envisioning using LLM class directly in the tool to call the Bedrock service, so having this code here will help. Let me know if you have a better way to handle this.

@3coins
Copy link
Contributor

3coins commented Jul 11, 2023

@baskaryan @efriis
Let @gauravrele87 or me know if we can do anything to move this forward, or if there is a better way to implemented this. Thanks for your help.

@efriis
Copy link
Member

efriis commented Jul 12, 2023

Hey @3coins @gauravrele87 ! Let's skip merging this into the LLM class because it doesn't make sense in the LLM abstraction.

We haven't put much thought into image generation abstractions yet, so in the meantime, would you mind implementing it in a similar fashion to langchain/tools/steamship_image_generation?

It would be amazing if you could factor out shared logic between these Bedrock APIs into a shared BedrockAPIWrapper class that both the new langchain.tools.bedrock_image_generation.BedrockStabilityTool and existing/refactored langchain.llms.bedrock.Bedrock inherit from. Feel free to keep it in langchain.llms.bedrock or put it in langchain.utilities.bedrock - up to you!

@3coins
Copy link
Contributor

3coins commented Jul 13, 2023

@efriis
Thanks for the guidance on this change. We will submit another PR with those updates, as it will require refactor for the Bedrock LLM.

@baskaryan
Copy link
Collaborator

@3coins ok to close this PR?

@leo-gan
Copy link
Collaborator

leo-gan commented Sep 18, 2023

Closing

@leo-gan leo-gan closed this Sep 18, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🤖:improvement Medium size change to existing code to handle new use-cases
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants