One of the principal features of Semantic Kernel is its ability to integrate various AI services seamlessly. We are pleased to announce that this capability now extends to AWS Bedrock. With AWS Bedrock, you can access foundational models such as the Amazon Titan models.
The new connector supports Chat Completion, Text Generation, and Text Embeddings, depending on the chosen model.
AWS Bedrock
AWS Bedrock is a fully managed service offering a serverless experience. It provides access to a diverse range of models from providers like Amazon, Anthropic, AI21 Labs, Cohere, and Meta, among others.
If you are a current AWS Bedrock user but have not yet explored Semantic Kernel, you can integrate it into your application to experience its ecosystem and extensive SDK features. For existing Semantic Kernel users, this integration offers an additional AI service to explore.
Getting Started
- Follow this guide to gain access to AWS Bedrock if you haven’t already.
- Upgrade to the latest version of Semantic Kernel.
Python
- Follow this guide to configure your environment to use the Bedrock API.
- Use the following script to get started:
import asyncio from semantic_kernel.connectors.ai.bedrock.bedrock_prompt_execution_settings import BedrockChatPromptExecutionSettings from semantic_kernel.connectors.ai.bedrock.services.bedrock_chat_completion import BedrockChatCompletion from semantic_kernel.contents import ChatHistory async def main(): service = BedrockChatCompletion(model_id="amazon.titan-text-premier-v1:0") chat_history = ChatHistory() chat_history.add_user_message("Hi! How are you?") response = await service.get_chat_message_content(chat_history, BedrockChatPromptExecutionSettings()) print(response) if __name__ == "__main__": asyncio.run(main())
- For a more complete sample that shows how to use the connector with a kernel and how to pass in model-specific settings, please refer to this GitHub sample.
.Net
- Follow this guide to configure your environment to use the Bedrock API.
- Use the following code to get started:
var kernel = Kernel.CreateBuilder() .AddBedrockChatCompletionService("amazon.titan-text-premier-v1:0") .Build() var chatCompletionService = kernel.GetRequiredService<IChatCompletionService>(); ChatHistory chatHistory = []; chatHistory.AddMessage(AuthorRole.User, "Hi! How are you?"); var response = await chatCompletionService.GetChatMessageContentAsync(chatHistory); Console.WriteLine(response);
Conclusion
The Semantic Kernel team is dedicated to empowering developers by providing access to the latest advancements in the industry. We have integrated the new AWS Bedrock connector into Semantic Kernel, allowing you to seamlessly incorporate another model provider into your SK-based applications. Additionally, we offer samples demonstrating the usage and potential of the new connector. This will give you greater confidence in selecting the appropriate models for your business requirements. We encourage you to leverage your creativity and build remarkable solutions with SK!
Please reach out if you have any questions or feedback through our Semantic Kernel GitHub Discussion Channel. We look forward to hearing from you! We would also love your support, if you’ve enjoyed using Semantic Kernel, give us a star on GitHub.
0 comments
Be the first to start the discussion.