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

Implement Microsoft.Extensions.AI's IChatClient / IEmbeddingGenerator for IAmazonBedrockRuntime #3545

Open
wants to merge 8 commits into
base: v4-development
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 42 additions & 2 deletions extensions/AWSSDK.Extensions.sln
Original file line number Diff line number Diff line change
Expand Up @@ -36,18 +36,28 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "CloudFront.Signers.Tests.Ne
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "EC2.DecryptPassword.NetStandard", "test\EC2.DecryptPasswordTests\EC2.DecryptPassword.NetStandard.csproj", "{EA6EEC77-E69B-4D42-B9F2-BADCEEE5A32B}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AWSSDK.CloudFront.NetStandard", "..\sdk\src\Services\CloudFront\AWSSDK.CloudFront.NetStandard.csproj", "{280223DF-ECB0-4B38-A3A6-B80B46D48475}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BedrockMEAITests.NetFramework", "test\BedrockMEAITests\BedrockMEAITests.NetFramework.csproj", "{D98D6380-80A3-4818-84B4-3BD332383CA2}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AWSSDK.BedrockRuntime.NetStandard", "..\sdk\src\Services\BedrockRuntime\AWSSDK.BedrockRuntime.NetStandard.csproj", "{280223DF-ECB0-4B38-A3A6-B80B46D48475}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AWSSDK.CloudFront.NetStandard", "..\sdk\src\Services\CloudFront\AWSSDK.CloudFront.NetStandard.csproj", "{71C8FC92-F868-4E07-B005-62180C1D6B8B}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AWSSDK.EC2.NetStandard", "..\sdk\src\Services\EC2\AWSSDK.EC2.NetStandard.csproj", "{FC70CF98-BA7E-4F9F-A5DB-966973284091}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AWSSDK.CloudFront.NetFramework", "..\sdk\src\Services\CloudFront\AWSSDK.CloudFront.NetFramework.csproj", "{4FFF9872-1D77-4664-83C6-B46AC6EB1E20}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AWSSDK.BedrockRuntime.NetFramework", "..\sdk\src\Services\BedrockRuntime\AWSSDK.BedrockRuntime.NetFramework.csproj", "{4FFF9872-1D77-4664-83C6-B46AC6EB1E20}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AWSSDK.CloudFront.NetFramework", "..\sdk\src\Services\CloudFront\AWSSDK.CloudFront.NetFramework.csproj", "{B416F870-421E-410A-8848-13A7F523E669}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AWSSDK.EC2.NetFramework", "..\sdk\src\Services\EC2\AWSSDK.EC2.NetFramework.csproj", "{0377B228-91F3-4A0B-BE66-221E7ECA6DF7}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AWSSDK.Extensions.CloudFront.Signers.NetFramework", "src\AWSSDK.Extensions.CloudFront.Signers\AWSSDK.Extensions.CloudFront.Signers.NetFramework.csproj", "{E195094D-5899-4FDF-969D-93C4432BA921}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AWSSDK.Extensions.EC2.DecryptPassword.NetFramework", "src\AWSSDK.Extensions.EC2.DecryptPassword\AWSSDK.Extensions.EC2.DecryptPassword.NetFramework.csproj", "{3EC669E6-A541-445E-B68E-0A853715E39C}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AWSSDK.Extensions.Bedrock.MEAI.NetFramework", "src\AWSSDK.Extensions.Bedrock.MEAI\AWSSDK.Extensions.Bedrock.MEAI.NetFramework.csproj", "{4A94F623-0C71-47BD-B927-CB6FA28D33A1}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AWSSDK.Extensions.Bedrock.MEAI.NetStandard", "src\AWSSDK.Extensions.Bedrock.MEAI\AWSSDK.Extensions.Bedrock.MEAI.NetStandard.csproj", "{B174860A-0D1B-4B7D-9E46-7DBFC9AA5AAB}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -102,10 +112,22 @@ Global
{EA6EEC77-E69B-4D42-B9F2-BADCEEE5A32B}.Debug|Any CPU.Build.0 = Debug|Any CPU
{EA6EEC77-E69B-4D42-B9F2-BADCEEE5A32B}.Release|Any CPU.ActiveCfg = Release|Any CPU
{EA6EEC77-E69B-4D42-B9F2-BADCEEE5A32B}.Release|Any CPU.Build.0 = Release|Any CPU
{B5244288-5997-4E72-8AD8-936D346C02CE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{B5244288-5997-4E72-8AD8-936D346C02CE}.Debug|Any CPU.Build.0 = Debug|Any CPU
{B5244288-5997-4E72-8AD8-936D346C02CE}.Release|Any CPU.ActiveCfg = Release|Any CPU
{B5244288-5997-4E72-8AD8-936D346C02CE}.Release|Any CPU.Build.0 = Release|Any CPU
{D98D6380-80A3-4818-84B4-3BD332383CA2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{D98D6380-80A3-4818-84B4-3BD332383CA2}.Debug|Any CPU.Build.0 = Debug|Any CPU
{D98D6380-80A3-4818-84B4-3BD332383CA2}.Release|Any CPU.ActiveCfg = Release|Any CPU
{D98D6380-80A3-4818-84B4-3BD332383CA2}.Release|Any CPU.Build.0 = Release|Any CPU
{280223DF-ECB0-4B38-A3A6-B80B46D48475}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{280223DF-ECB0-4B38-A3A6-B80B46D48475}.Debug|Any CPU.Build.0 = Debug|Any CPU
{280223DF-ECB0-4B38-A3A6-B80B46D48475}.Release|Any CPU.ActiveCfg = Release|Any CPU
{280223DF-ECB0-4B38-A3A6-B80B46D48475}.Release|Any CPU.Build.0 = Release|Any CPU
{71C8FC92-F868-4E07-B005-62180C1D6B8B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{71C8FC92-F868-4E07-B005-62180C1D6B8B}.Debug|Any CPU.Build.0 = Debug|Any CPU
{71C8FC92-F868-4E07-B005-62180C1D6B8B}.Release|Any CPU.ActiveCfg = Release|Any CPU
{71C8FC92-F868-4E07-B005-62180C1D6B8B}.Release|Any CPU.Build.0 = Release|Any CPU
{FC70CF98-BA7E-4F9F-A5DB-966973284091}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{FC70CF98-BA7E-4F9F-A5DB-966973284091}.Debug|Any CPU.Build.0 = Debug|Any CPU
{FC70CF98-BA7E-4F9F-A5DB-966973284091}.Release|Any CPU.ActiveCfg = Release|Any CPU
Expand All @@ -114,6 +136,10 @@ Global
{4FFF9872-1D77-4664-83C6-B46AC6EB1E20}.Debug|Any CPU.Build.0 = Debug|Any CPU
{4FFF9872-1D77-4664-83C6-B46AC6EB1E20}.Release|Any CPU.ActiveCfg = Release|Any CPU
{4FFF9872-1D77-4664-83C6-B46AC6EB1E20}.Release|Any CPU.Build.0 = Release|Any CPU
{B416F870-421E-410A-8848-13A7F523E669}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{B416F870-421E-410A-8848-13A7F523E669}.Debug|Any CPU.Build.0 = Debug|Any CPU
{B416F870-421E-410A-8848-13A7F523E669}.Release|Any CPU.ActiveCfg = Release|Any CPU
{B416F870-421E-410A-8848-13A7F523E669}.Release|Any CPU.Build.0 = Release|Any CPU
{0377B228-91F3-4A0B-BE66-221E7ECA6DF7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{0377B228-91F3-4A0B-BE66-221E7ECA6DF7}.Debug|Any CPU.Build.0 = Debug|Any CPU
{0377B228-91F3-4A0B-BE66-221E7ECA6DF7}.Release|Any CPU.ActiveCfg = Release|Any CPU
Expand All @@ -126,6 +152,14 @@ Global
{3EC669E6-A541-445E-B68E-0A853715E39C}.Debug|Any CPU.Build.0 = Debug|Any CPU
{3EC669E6-A541-445E-B68E-0A853715E39C}.Release|Any CPU.ActiveCfg = Release|Any CPU
{3EC669E6-A541-445E-B68E-0A853715E39C}.Release|Any CPU.Build.0 = Release|Any CPU
{4A94F623-0C71-47BD-B927-CB6FA28D33A1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{4A94F623-0C71-47BD-B927-CB6FA28D33A1}.Debug|Any CPU.Build.0 = Debug|Any CPU
{4A94F623-0C71-47BD-B927-CB6FA28D33A1}.Release|Any CPU.ActiveCfg = Release|Any CPU
{4A94F623-0C71-47BD-B927-CB6FA28D33A1}.Release|Any CPU.Build.0 = Release|Any CPU
{B174860A-0D1B-4B7D-9E46-7DBFC9AA5AAB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{B174860A-0D1B-4B7D-9E46-7DBFC9AA5AAB}.Debug|Any CPU.Build.0 = Debug|Any CPU
{B174860A-0D1B-4B7D-9E46-7DBFC9AA5AAB}.Release|Any CPU.ActiveCfg = Release|Any CPU
{B174860A-0D1B-4B7D-9E46-7DBFC9AA5AAB}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand All @@ -143,12 +177,18 @@ Global
{C8A027AB-282C-400E-893D-971A5D55DB17} = {3D822DC2-ED2E-4434-BC4F-CE7FCD846B02}
{A552BA51-D17C-4594-BF0A-DF7F53EA688D} = {A960D001-40B3-4B1A-A890-D1049FB7586E}
{EA6EEC77-E69B-4D42-B9F2-BADCEEE5A32B} = {A960D001-40B3-4B1A-A890-D1049FB7586E}
{B5244288-5997-4E72-8AD8-936D346C02CE} = {A960D001-40B3-4B1A-A890-D1049FB7586E}
{D98D6380-80A3-4818-84B4-3BD332383CA2} = {A960D001-40B3-4B1A-A890-D1049FB7586E}
{280223DF-ECB0-4B38-A3A6-B80B46D48475} = {0BA39F07-84D6-420B-82D3-6DC3AF016C65}
{71C8FC92-F868-4E07-B005-62180C1D6B8B} = {0BA39F07-84D6-420B-82D3-6DC3AF016C65}
{FC70CF98-BA7E-4F9F-A5DB-966973284091} = {0BA39F07-84D6-420B-82D3-6DC3AF016C65}
{4FFF9872-1D77-4664-83C6-B46AC6EB1E20} = {0BA39F07-84D6-420B-82D3-6DC3AF016C65}
{B416F870-421E-410A-8848-13A7F523E669} = {0BA39F07-84D6-420B-82D3-6DC3AF016C65}
{0377B228-91F3-4A0B-BE66-221E7ECA6DF7} = {0BA39F07-84D6-420B-82D3-6DC3AF016C65}
{E195094D-5899-4FDF-969D-93C4432BA921} = {3D822DC2-ED2E-4434-BC4F-CE7FCD846B02}
{3EC669E6-A541-445E-B68E-0A853715E39C} = {3D822DC2-ED2E-4434-BC4F-CE7FCD846B02}
{4A94F623-0C71-47BD-B927-CB6FA28D33A1} = {3D822DC2-ED2E-4434-BC4F-CE7FCD846B02}
{B174860A-0D1B-4B7D-9E46-7DBFC9AA5AAB} = {3D822DC2-ED2E-4434-BC4F-CE7FCD846B02}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {949367A4-5683-4FD3-93F4-A2CEA6EECB21}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net472</TargetFramework>
<AssemblyName>AWSSDK.Extensions.Bedrock.MEAI</AssemblyName>
<PackageId>AWSSDK.Extensions.Bedrock.MEAI</PackageId>

<GenerateAssemblyTitleAttribute>false</GenerateAssemblyTitleAttribute>
<GenerateAssemblyConfigurationAttribute>false</GenerateAssemblyConfigurationAttribute>
<GenerateAssemblyCompanyAttribute>false</GenerateAssemblyCompanyAttribute>
<GenerateAssemblyProductAttribute>false</GenerateAssemblyProductAttribute>
<GenerateAssemblyDescriptionAttribute>false</GenerateAssemblyDescriptionAttribute>
<GenerateAssemblyCopyrightAttribute>false</GenerateAssemblyCopyrightAttribute>
<GenerateAssemblyVersionAttribute>false</GenerateAssemblyVersionAttribute>
<GenerateAssemblyFileVersionAttribute>false</GenerateAssemblyFileVersionAttribute>
<GenerateDocumentationFile>true</GenerateDocumentationFile>

<LangVersion>Latest</LangVersion>
<Nullable>enable</Nullable>
</PropertyGroup>

<ItemGroup>
<Compile Remove="**/obj/**" />
</ItemGroup>

<Choose>
<When Condition=" '$(AWSKeyFile)' == '' ">
<PropertyGroup>
<AssemblyOriginatorKeyFile>..\..\..\sdk\awssdk.dll.snk</AssemblyOriginatorKeyFile>
</PropertyGroup>
</When>
<Otherwise>
<PropertyGroup>
<AssemblyOriginatorKeyFile>$(AWSKeyFile)</AssemblyOriginatorKeyFile>
</PropertyGroup>
</Otherwise>
</Choose>

<ItemGroup>
<PackageReference Include="Microsoft.Extensions.AI.Abstractions" Version="9.0.1-preview.1.24570.5" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="../../../sdk/src/Core/AWSSDK.Core.NetFramework.csproj" />
<ProjectReference Include="../../../sdk/src/Services/BedrockRuntime/AWSSDK.BedrockRuntime.NetFramework.csproj" />
</ItemGroup>
</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>netstandard2.0;net8.0</TargetFrameworks>
<AssemblyName>AWSSDK.Extensions.Bedrock.MEAI</AssemblyName>
<PackageId>AWSSDK.Extensions.Bedrock.MEAI</PackageId>

<GenerateAssemblyTitleAttribute>false</GenerateAssemblyTitleAttribute>
<GenerateAssemblyConfigurationAttribute>false</GenerateAssemblyConfigurationAttribute>
<GenerateAssemblyCompanyAttribute>false</GenerateAssemblyCompanyAttribute>
<GenerateAssemblyProductAttribute>false</GenerateAssemblyProductAttribute>
<GenerateAssemblyDescriptionAttribute>false</GenerateAssemblyDescriptionAttribute>
<GenerateAssemblyCopyrightAttribute>false</GenerateAssemblyCopyrightAttribute>
<GenerateAssemblyVersionAttribute>false</GenerateAssemblyVersionAttribute>
<GenerateAssemblyFileVersionAttribute>false</GenerateAssemblyFileVersionAttribute>
<GenerateDocumentationFile>true</GenerateDocumentationFile>

<LangVersion>Latest</LangVersion>
Copy link
Contributor

Choose a reason for hiding this comment

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

I'll let @normj chime in here, but normally we don't set the LangVersion for NetStandard and NetFramework projects, but since this is an extension package I think there is more flexibility here. For example, I see the null forgiving operator sprinkled in the PR but if we dropped the LangVersion we wouldn't be able to use that. (For NetStandard2.0 at least). I don't see a problem with it myself

Copy link
Author

Choose a reason for hiding this comment

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

Thanks. My preference is always to use the latest language version and to keep the code as modern as possible, but I'm happy to adapt to whatever you'd like here.

<Nullable>enable</Nullable>
</PropertyGroup>

<PropertyGroup Condition="'$(TargetFramework)' == 'net8.0'">
<IsTrimmable>true</IsTrimmable>
</PropertyGroup>

<ItemGroup>
<Compile Remove="**/obj/**" />
</ItemGroup>

<Choose>
<When Condition=" '$(AWSKeyFile)' == '' ">
<PropertyGroup>
<AssemblyOriginatorKeyFile>..\..\..\sdk\awssdk.dll.snk</AssemblyOriginatorKeyFile>
</PropertyGroup>
</When>
<Otherwise>
<PropertyGroup>
<AssemblyOriginatorKeyFile>$(AWSKeyFile)</AssemblyOriginatorKeyFile>
</PropertyGroup>
</Otherwise>
</Choose>

<ItemGroup>
<PackageReference Include="Microsoft.Extensions.AI.Abstractions" Version="9.0.1-preview.1.24570.5" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="../../../sdk/src/Core/AWSSDK.Core.NetStandard.csproj" />
<ProjectReference Include="../../../sdk/src/Services/BedrockRuntime/AWSSDK.BedrockRuntime.NetStandard.csproj" />
</ItemGroup>
</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
<?xml version="1.0" encoding="utf-8"?>
<package>
<metadata>
<id>AWSSDK.Extensions.Bedrock.MEAI</id>
<title>AWSSDK - Bedrock integration with Microsoft.Extensions.AI.</title>
<version>4.0.0.0-preview.4</version>
<authors>Amazon Web Services</authors>
<description>Implementations of Microsoft.Extensions.AI's abstractions for Bedrock.</description>
<language>en-US</language>
<license type="expression">Apache-2.0</license>
<projectUrl>https://github.com/aws/aws-sdk-net/</projectUrl>
<tags>AWS Amazon aws-sdk-v4</tags>
<icon>images\AWSLogo.png</icon>
<dependencies>
<group targetFramework="net472">
<dependency id="AWSSDK.Core" version="4.0.0.0-preview.4" />
<dependency id="Microsoft.Extensions.AI.Abstractions" version="9.0.1-preview.1.24570.5" />
</group>
<group targetFramework="netstandard2.0">
<dependency id="AWSSDK.Core" version="4.0.0.0-preview.4" />
<dependency id="Microsoft.Extensions.AI.Abstractions" version="9.0.1-preview.1.24570.5" />
</group>
<group targetFramework="net8.0">
<dependency id="AWSSDK.Core" version="4.0.0.0-preview.4" />
<dependency id="Microsoft.Extensions.AI.Abstractions" version="9.0.1-preview.1.24570.5" />
</group>
</dependencies>
</metadata>
<files>
<file src="..\..\..\sdk\nuget-content\AWSLogo.png" target="images\" />

<file src=".\bin\Release\net472\AWSSDK.Extensions.Bedrock.MEAI.dll" target="lib\net472" />
<file src=".\bin\Release\net472\AWSSDK.Extensions.Bedrock.MEAI.pdb" target="lib\net472" />
<file src=".\bin\Release\net472\AWSSDK.Extensions.Bedrock.MEAI.xml" target="lib\net472" />

<file src=".\bin\Release\netstandard2.0\AWSSDK.Extensions.Bedrock.MEAI.dll" target="lib\netstandard2.0"/>
<file src=".\bin\Release\netstandard2.0\AWSSDK.Extensions.Bedrock.MEAI.pdb" target="lib\netstandard2.0"/>
<file src=".\bin\Release\netstandard2.0\AWSSDK.Extensions.Bedrock.MEAI.xml" target="lib\netstandard2.0" />

<file src=".\bin\Release\net8.0\AWSSDK.Extensions.Bedrock.MEAI.dll" target="lib\net8.0" />
<file src=".\bin\Release\net8.0\AWSSDK.Extensions.Bedrock.MEAI.pdb" target="lib\net8.0" />
<file src=".\bin\Release\net8.0\AWSSDK.Extensions.Bedrock.MEAI.xml" target="lib\net8.0" />
</files>
</package>
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
/*
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License").
* You may not use this file except in compliance with the License.
* A copy of the License is located at
*
* http://aws.amazon.com/apache2.0
*
* or in the "license" file accompanying this file. This file is distributed
* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
* express or implied. See the License for the specific language governing
* permissions and limitations under the License.
*/

using Microsoft.Extensions.AI;
using System;

namespace Amazon.BedrockRuntime;

/// <summary>Provides extensions for working with <see cref="IAmazonBedrockRuntime"/> instances.</summary>
public static class AmazonBedrockRuntimeExtensions
{
/// <summary>Gets an <see cref="IChatClient"/> for the specified <see cref="IAmazonBedrockRuntime"/> instance.</summary>
/// <param name="runtime">The runtime instance to be represented as an <see cref="IChatClient"/>.</param>
/// <param name="modelId">
/// The default model ID to use when no model is specified in a request. If not specified,
/// a model must be provided in the <see cref="ChatOptions.ModelId"/> passed to <see cref="IChatClient.CompleteAsync"/>
/// or <see cref="IChatClient.CompleteStreamingAsync"/>.
/// </param>
/// <returns>A <see cref="IChatClient"/> instance representing the <see cref="IAmazonBedrockRuntime"/> instance.</returns>
/// <exception cref="ArgumentNullException"><paramref name="runtime"/> is <see langword="null"/>.</exception>
public static IChatClient AsChatClient(this IAmazonBedrockRuntime runtime, string? modelId = null) =>
runtime is not null ? new BedrockChatClient(runtime, modelId) :
throw new ArgumentNullException(nameof(runtime));

/// <summary>Gets an <see cref="IChatClient"/> for the specified <see cref="IAmazonBedrockRuntime"/> instance.</summary>
/// <param name="runtime">The runtime instance to be represented as an <see cref="IChatClient"/>.</param>
/// <param name="modelId">
/// The default model ID to use when no model is specified in a request. If not specified,
/// a model must be provided in the <see cref="ChatOptions.ModelId"/> passed to <see cref="IChatClient.CompleteAsync"/>
/// or <see cref="IChatClient.CompleteStreamingAsync"/>.
/// </param>
/// <param name="dimensions">
/// The default number of dimensions to request be generated. This will be overridden by a <see cref="EmbeddingGenerationOptions.Dimensions"/>
/// if that is specified to a request. If neither is specified, the default for the model will be used.
/// </param>
/// <returns>A <see cref="IChatClient"/> instance representing the <see cref="IAmazonBedrockRuntime"/> instance.</returns>
/// <exception cref="ArgumentNullException"><paramref name="runtime"/> is <see langword="null"/>.</exception>
public static IEmbeddingGenerator<string, Embedding<float>> AsEmbeddingGenerator(
this IAmazonBedrockRuntime runtime, string? modelId = null, int? dimensions = null) =>
runtime is not null ? new BedrockEmbeddingGenerator(runtime, modelId, dimensions) :
throw new ArgumentNullException(nameof(runtime));
}
Loading