Skip to content

.Net: Add Bedrock Connector - #7587

Merged
Roger Barreto (rogerbarreto) merged 154 commits into
microsoft:feature-connectors-amazonfrom
as14692:feature-connectors-amazon
Aug 14, 2024
Merged

Roger Barreto (rogerbarreto) merged 154 commits into
microsoft:feature-connectors-amazonfrom
as14692:feature-connectors-amazon

Conversation

@charlizeyeh

@charlizeyeh Charlize Yeh (charlizeyeh) commented Jul 31, 2024 •

Copy link
Copy Markdown
Contributor

Motivation and Context

There has been a strong demand from developers in the community to be able to utilize Bedrock with the Semantic Kernel. With the wide variety of foundation models offered including specialized models tailored for various domains and use cases, Bedrock's AI capabilities can now be leveraged within the Semantic Kernel's unified ecosystem with this connector.

Description

This pull request implements a connector for Amazon Bedrock, allowing developers to leverage Bedrock's foundation models within the Semantic Kernel framework. Key features of this implementation include:

  • Core Services: Implementation of IChatCompletionService and ITextGenerationService from the Semantic Kernel.
  • Authentication and Security: Secure client authentication and API communication with the Amazon Bedrock Runtime.
  • Modular Design: A directory organization and namespace structure similar to other connectors in the Semantic Kernel, including folders for core, services, models, and extensions.
  • Testing: Inclusion of unit tests and integration tests for available Bedrock models to demonstrate successful communication with Bedrock API, request/response mapping, and output generation.

The implementation leverages the following Amazon Bedrock Runtime actions:

  • InvokeModelAsync and InvokeModelWithResponseStreamAsync for GetTextContentsAsync and GetStreamingTextContentsAsync, respectively.
  • ConverseAsync and ConverseStreamAsync for GetChatMessageContentsAsync and GetStreamingChatMessageContentsAsync, respectively.

The following base models from various providers are currently connected and available for use under Bedrock:

  • AI21 Labs Jamba
  • AI21 Labs Jurassic-2 series
  • Amazon Titan
  • Anthropic Claude
  • Cohere Command
  • Meta Llama 3
  • Mistral AI Mistral

The kernel builder extension methods support two authentication scenarios:

  • User-provided IAmazonBedrockRuntime object: Developers can provide a pre-configured IAmazonBedrockRuntime object, allowing for customized configurations such as specifying custom credentials, endpoints, or other settings.
  • Automatic IAmazonBedrockRuntime creation: If developers do not provide an IAmazonBedrockRuntime object, an instance is automatically created and registered in the dependency injection (DI) container using the AWSSDK.Extensions.NETCore.Setup package. In this case, the IAmazonBedrockRuntime object will be configured with default settings, such as credentials obtained from environment variables, AWS credentials files, or instance profile credentials.

Resolve #3094
Resolve #4335

Contribution Checklist

@charlizeyeh

Copy link
Copy Markdown
Contributor Author

Apologies, I think there were extra usings in execution settings classes. dotnet format should be fixed now

@rogerbarreto

Roger Barreto (rogerbarreto) commented Aug 13, 2024 •

Copy link
Copy Markdown
Member

I still see some XmlDocs without description for params and return, suggest doing a full overview.

Search for should help:

  • <returns></returns>
  • ></param>

Overall LGTM

@rogerbarreto

Roger Barreto (rogerbarreto) commented Aug 13, 2024 •

Copy link
Copy Markdown
Member

The usings I believe you will only be able to solve, removing the <ImplicitUsings>enable</ImplicitUsings> from the .csproj

@rogerbarreto Roger Barreto (rogerbarreto) left a comment •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Charlize Yeh (@charlizeyeh) Thank you soo much for all changes made. Tomorrow plan to merge this in the feature branch.

@rogerbarreto
Roger Barreto (rogerbarreto) merged commit 95b82dd into microsoft:feature-connectors-amazon Aug 14, 2024
@charlizeyeh

Copy link
Copy Markdown
Contributor Author

Roger Barreto (@RogerBarret0)
Thank you for taking the time to review and excited to have this merged! The next PR (which adds text embedding and text to image service will include the prompt execution settings naming update). One question - will this branch be merged with main and if so, are there any steps on our end for that?

@rogerbarreto

Roger Barreto (rogerbarreto) commented Aug 19, 2024 •

Copy link
Copy Markdown
Member

Charlize Yeh (@charlizeyeh), yes, all connectors feature branches as of now intend to merge in main at some point.
The merging in main process goes around more series of reviews PR in the future and may arise as the team analyses it. Normally I try to do the most of this checks but another suggestions may come as part of it. From your side I just need to understand what are the missing features you plan to add prior to merging.

One feature that we want to add as part of the connectors is Function Calling/Tool Calling using our SK AutoFunctionInvocation abstractions but this is currently being finalized by SergeyMenshykh.

@halllo

Copy link
Copy Markdown

Charlize Yeh (@charlizeyeh) thanks for your connector! I am looking forward to using it. Does it already support function calling (with Claude)?

@as14692

Anushka Srinivasa (as14692) commented Sep 5, 2024 •

Copy link
Copy Markdown

Charlize Yeh (@charlizeyeh), yes, all connectors feature branches as of now intend to merge in main at some point. The merging in main process goes around more series of reviews PR in the future and may arise as the team analyses it. Normally I try to do the most of this checks but another suggestions may come as part of it. From your side I just need to understand what are the missing features you plan to add prior to merging.

One feature that we want to add as part of the connectors is Function Calling/Tool Calling using our SK AutoFunctionInvocation abstractions but this is currently being finalized by SergeyMenshykh.

Roger Barreto (@RogerBarret0) Could you please merge this PR into main which has the implementation of IChatCompletionService and ITextGenerationService. We will publish a new PR for the Function Calling/Tool Calling once the abstractions are ready. I will be contributing to the .NET Bedrock connector moving forward.

@Beau-Gosse-dev

Copy link
Copy Markdown

Roger Barreto (@rogerbarreto) Any update on the question above? We'd love to get this out.

@rogerbarreto

Copy link
Copy Markdown
Member

Beau Gosse (@Beau-Gosse-dev) yes, we have plan on moving this one forward next sprint 35 (Sep-23 / Oct-06).

@rogerbarreto

Copy link
Copy Markdown
Member

Do you have models for TextEmbeddings? Would be nice to have some options for the ITextEmbeddingGenerationService interface in the connector.

@Beau-Gosse-dev

Copy link
Copy Markdown

Roger Barreto (@rogerbarreto) Thanks for the update. There is a first draft of TextEmbeddings support in our fork, but we've been pulled into other priorities at the moment and wouldn't be able to get it fully ready before your next sprint, so hopefully the first release can go without it and we can support TextEmbeddings in a later release.

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

Labels

documentation kernel Issues or pull requests impacting the core kernel .NET Issue or Pull requests regarding .NET code

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

10 participants