Skip to content

Commit 528812a

Browse files
Merge pull request #37 from aws/gcbeatty/meai-upgrade-meai-abstractions
Upgrade Microsoft.Extensions.AI.Abstractions to 10.8.3
2 parents bf8cc97 + 467ec48 commit 528812a

24 files changed

Lines changed: 9959 additions & 5 deletions

.autover/autover.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,10 @@
1010
{
1111
"Name": "AWS.AgentCore.Testing",
1212
"Path": "src/AWS.AgentCore.Testing/AWS.AgentCore.Testing.csproj"
13+
},
14+
{
15+
"Name": "AWS.Bedrock.MEAI",
16+
"Path": "src/AWS.Bedrock.MEAI/AWS.Bedrock.MEAI.csproj"
1317
}
1418
],
1519
"UseCommitsForChangelog": false,
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"Projects": [
3+
{
4+
"Name": "AWS.Bedrock.MEAI",
5+
"Type": "Major",
6+
"ChangelogMessages": [
7+
"Migrated the Bedrock Microsoft.Extensions.AI integration into the aws-dotnet-ai repository. This package was previously published as AWSSDK.Extensions.Bedrock.MEAI from the aws-sdk-net repository. The AmazonBedrockRuntimeExtensions methods remain in the Amazon.BedrockRuntime namespace; the package's other types now live in the AWS.Bedrock.MEAI namespace."
8+
]
9+
}
10+
]
11+
}
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,14 @@
1515
<Project Path="src/AWS.AgentCore.SourceGenerator/AWS.AgentCore.SourceGenerator.csproj" />
1616
<Project Path="src/AWS.AgentCore.Hosting/AWS.AgentCore.Hosting.csproj" />
1717
<Project Path="src/AWS.AgentCore.Testing/AWS.AgentCore.Testing.csproj" />
18+
<Project Path="src/AWS.Bedrock.MEAI/AWS.Bedrock.MEAI.csproj" />
1819
</Folder>
1920
<Folder Name="/test/">
2021
<Project Path="test/AWS.AgentCore.Hosting.UnitTests/AWS.AgentCore.Hosting.UnitTests.csproj" />
2122
<Project Path="test/AWS.AgentCore.Testing.UnitTests/AWS.AgentCore.Testing.UnitTests.csproj" />
2223
<Project Path="test/AWS.AgentCore.Testing.IntegrationTests/AWS.AgentCore.Testing.IntegrationTests.csproj" />
2324
<Project Path="test/AWS.AgentCore.SourceGenerator.UnitTests/AWS.AgentCore.SourceGenerator.UnitTests.csproj" />
2425
<Project Path="test/AWS.AgentCore.Hosting.IntegrationTests/AWS.AgentCore.Hosting.IntegrationTests.csproj" />
26+
<Project Path="test/AWS.Bedrock.MEAI.UnitTests/AWS.Bedrock.MEAI.UnitTests.csproj" />
2527
</Folder>
2628
</Solution>

CONTRIBUTING.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ The available projects are:
7979

8080
- AWS.AgentCore.Hosting
8181
- AWS.AgentCore.Testing
82+
- AWS.Bedrock.MEAI
8283

8384
The possible increment types are:
8485

buildtools/ci.buildspec.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ phases:
1212

1313
build:
1414
commands:
15-
- dotnet build AWS.AgentCore.slnx -c Release
16-
- dotnet test AWS.AgentCore.slnx -c Release --no-build --logger trx --logger "console;verbosity=detailed" --results-directory ./testresults
15+
- dotnet build AWS.DotNetAI.slnx -c Release
16+
- dotnet test AWS.DotNetAI.slnx -c Release --no-build --logger trx --logger "console;verbosity=detailed" --results-directory ./testresults
1717
reports:
1818
aws-dotnet-ai-tests:
1919
file-format: VisualStudioTrx

src/AWS.AgentCore.Hosting/AWS.AgentCore.Hosting.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@
3232
<FrameworkReference Include="Microsoft.AspNetCore.App" />
3333
<PackageReference Include="AWSSDK.BedrockAgentCore" Version="4.0.23" />
3434
<PackageReference Include="AWSSDK.BedrockRuntime" Version="4.0.17.5" />
35-
<PackageReference Include="AWSSDK.Extensions.Bedrock.MEAI" Version="4.0.6.12" />
3635
<PackageReference Include="AWSSDK.Extensions.NETCore.Setup" Version="4.0.3.35" />
3736
<PackageReference Include="Microsoft.Agents.AI" Version="1.3.0" />
3837
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="10.0.300" PrivateAssets="All" />
@@ -41,6 +40,7 @@
4140

4241
<ItemGroup>
4342
<ProjectReference Include="..\AWS.AgentCore.SourceGenerator\AWS.AgentCore.SourceGenerator.csproj" PrivateAssets="all" ReferenceOutputAssembly="false" OutputItemType="Analyzer" SetTargetFramework="TargetFramework=netstandard2.0" />
43+
<ProjectReference Include="..\AWS.Bedrock.MEAI\AWS.Bedrock.MEAI.csproj" />
4444
</ItemGroup>
4545

4646
<PropertyGroup>
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<PropertyGroup>
4+
<TargetFrameworks>net472;netstandard2.0;net8.0</TargetFrameworks>
5+
<Nullable>enable</Nullable>
6+
<LangVersion>Latest</LangVersion>
7+
<Version>1.0.0</Version>
8+
<IsPackable>true</IsPackable>
9+
<PackageId>AWS.Bedrock.MEAI</PackageId>
10+
<Product>AI Integrations on AWS for .NET</Product>
11+
<Authors>Amazon Web Services</Authors>
12+
<Company>Amazon Web Services</Company>
13+
<Description>Implementations of Microsoft.Extensions.AI's abstractions for Amazon Bedrock.</Description>
14+
<PackageTags>AWS;Amazon;Bedrock;AI;Microsoft.Extensions.AI;IChatClient;IEmbeddingGenerator</PackageTags>
15+
<PackageProjectUrl>https://github.com/aws/aws-dotnet-ai</PackageProjectUrl>
16+
<PackageLicenseExpression>Apache-2.0</PackageLicenseExpression>
17+
<PackageIcon>icon.png</PackageIcon>
18+
<PackageReadmeFile>README.md</PackageReadmeFile>
19+
<GenerateDocumentationFile>true</GenerateDocumentationFile>
20+
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
21+
<WarningsAsErrors>true</WarningsAsErrors>
22+
<NoWarn>$(NoWarn);MEAI001</NoWarn>
23+
<SignAssembly>true</SignAssembly>
24+
<AssemblyOriginatorKeyFile>..\..\public.snk</AssemblyOriginatorKeyFile>
25+
<PublishRepositoryUrl>true</PublishRepositoryUrl>
26+
<EmbedUntrackedSources>true</EmbedUntrackedSources>
27+
<IncludeSymbols>true</IncludeSymbols>
28+
<SymbolPackageFormat>snupkg</SymbolPackageFormat>
29+
</PropertyGroup>
30+
31+
<!-- Trimming is only supported on net8.0+; the realtime (Nova Sonic) APIs are net8.0-only. -->
32+
<PropertyGroup Condition="$([MSBuild]::GetTargetFrameworkIdentifier('$(TargetFramework)')) == '.NETCoreApp' And $([MSBuild]::VersionGreaterThanOrEquals($([MSBuild]::GetTargetFrameworkVersion('$(TargetFramework)')), '8.0'))">
33+
<IsTrimmable>true</IsTrimmable>
34+
</PropertyGroup>
35+
36+
<ItemGroup>
37+
<PackageReference Include="AWSSDK.BedrockRuntime" Version="4.0.17.5" />
38+
<PackageReference Include="Microsoft.Extensions.AI.Abstractions" Version="10.8.3" />
39+
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="10.0.300" PrivateAssets="All" />
40+
</ItemGroup>
41+
42+
<!-- Reference assemblies so net472 compiles on Linux CI (CodeBuild has .NET only). -->
43+
<ItemGroup Condition="$([MSBuild]::GetTargetFrameworkIdentifier('$(TargetFramework)')) == '.NETFramework'">
44+
<PackageReference Include="Microsoft.NETFramework.ReferenceAssemblies" Version="1.0.3" PrivateAssets="All" />
45+
</ItemGroup>
46+
47+
<ItemGroup>
48+
<InternalsVisibleTo Include="AWS.Bedrock.MEAI.UnitTests, PublicKey=0024000004800000940000000602000000240000525341310004000001000100db5f59f098d27276c7833875a6263a3cc74ab17ba9a9df0b52aedbe7252745db7274d5271fd79c1f08f668ecfa8eaab5626fa76adc811d3c8fc55859b0d09d3bc0a84eecd0ba891f2b8a2fc55141cdcc37c2053d53491e650a479967c3622762977900eddbf1252ed08a2413f00a28f3a0752a81203f03ccb7f684db373518b4" />
49+
</ItemGroup>
50+
51+
<ItemGroup>
52+
<None Include="..\..\icon.png" Pack="true" PackagePath="" />
53+
<None Include="..\..\LICENSE" Pack="true" PackagePath="" />
54+
<None Include="..\..\NOTICE" Pack="true" PackagePath="" />
55+
<None Include=".\README.md" Pack="true" PackagePath="" />
56+
</ItemGroup>
57+
58+
</Project>
Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2+
// SPDX-License-Identifier: Apache-2.0
3+
4+
using AWS.Bedrock.MEAI;
5+
using Microsoft.Extensions.AI;
6+
using System;
7+
using System.Diagnostics.CodeAnalysis;
8+
9+
namespace Amazon.BedrockRuntime;
10+
11+
/// <summary>Provides extensions for working with <see cref="IAmazonBedrockRuntime"/> instances.</summary>
12+
public static class AmazonBedrockRuntimeExtensions
13+
{
14+
/// <summary>The provider name to use in metadata.</summary>
15+
internal const string ProviderName = "aws.bedrock";
16+
17+
#if NET8_0_OR_GREATER
18+
/// <summary>Gets an <see cref="IRealtimeClient"/> for the specified <see cref="IAmazonBedrockRuntime"/> instance.</summary>
19+
/// <param name="runtime">The runtime instance to be represented as an <see cref="IRealtimeClient"/>.</param>
20+
/// <param name="defaultModelId">
21+
/// The default model ID to use when no model is specified in session options. If not specified,
22+
/// a model must be provided in the <see cref="RealtimeSessionOptions.Model"/> passed to
23+
/// <see cref="IRealtimeClient.CreateSessionAsync"/>.
24+
/// </param>
25+
/// <returns>An <see cref="IRealtimeClient"/> instance representing the <see cref="IAmazonBedrockRuntime"/> instance.</returns>
26+
/// <exception cref="ArgumentNullException"><paramref name="runtime"/> is <see langword="null"/>.</exception>
27+
[Experimental("MEAI001")]
28+
public static IRealtimeClient AsIRealtimeClient(this IAmazonBedrockRuntime runtime, string? defaultModelId = null) =>
29+
runtime is not null ? new BedrockNovaRealtimeClient(runtime, defaultModelId) :
30+
throw new ArgumentNullException(nameof(runtime));
31+
#endif
32+
33+
/// <summary>Gets an <see cref="IChatClient"/> for the specified <see cref="IAmazonBedrockRuntime"/> instance.</summary>
34+
/// <param name="runtime">The runtime instance to be represented as an <see cref="IChatClient"/>.</param>
35+
/// <param name="defaultModelId">
36+
/// The default model ID to use when no model is specified in a request. If not specified,
37+
/// a model must be provided in the <see cref="ChatOptions.ModelId"/> passed to <see cref="IChatClient.GetResponseAsync"/>
38+
/// or <see cref="IChatClient.GetStreamingResponseAsync"/>.
39+
/// </param>
40+
/// <returns>A <see cref="IChatClient"/> instance representing the <see cref="IAmazonBedrockRuntime"/> instance.</returns>
41+
/// <exception cref="ArgumentNullException"><paramref name="runtime"/> is <see langword="null"/>.</exception>
42+
public static IChatClient AsIChatClient(this IAmazonBedrockRuntime runtime, string? defaultModelId = null) =>
43+
runtime is not null ? new BedrockChatClient(runtime, defaultModelId) :
44+
throw new ArgumentNullException(nameof(runtime));
45+
46+
/// <summary>Gets an <see cref="IChatClient"/> for the specified <see cref="IAmazonBedrockRuntime"/> instance.</summary>
47+
/// <param name="runtime">The runtime instance to be represented as an <see cref="IChatClient"/>.</param>
48+
/// <param name="defaultModelId">
49+
/// The default model ID to use when no model is specified in a request. If not specified,
50+
/// a model must be provided in the <see cref="ChatOptions.ModelId"/> passed to <see cref="IChatClient.GetResponseAsync"/>
51+
/// or <see cref="IChatClient.GetStreamingResponseAsync"/>.
52+
/// </param>
53+
/// <param name="structuredOutputMode">
54+
/// Controls how <see cref="ChatOptions.ResponseFormat"/> is realized.
55+
/// <see cref="BedrockStructuredOutputMode.Native"/> uses Bedrock native structured outputs
56+
/// (composes with user-provided tools and supports streaming) and requires a model that supports
57+
/// the feature. Use <see cref="BedrockStructuredOutputMode.SyntheticTool"/> for models without
58+
/// native support.
59+
/// </param>
60+
/// <returns>A <see cref="IChatClient"/> instance representing the <see cref="IAmazonBedrockRuntime"/> instance.</returns>
61+
/// <exception cref="ArgumentNullException"><paramref name="runtime"/> is <see langword="null"/>.</exception>
62+
public static IChatClient AsIChatClient(this IAmazonBedrockRuntime runtime, string? defaultModelId,
63+
BedrockStructuredOutputMode structuredOutputMode) =>
64+
runtime is not null ? new BedrockChatClient(runtime, defaultModelId, structuredOutputMode) :
65+
throw new ArgumentNullException(nameof(runtime));
66+
67+
/// <summary>Gets an <see cref="IEmbeddingGenerator{TInput, TEmbedding}"/> for the specified <see cref="IAmazonBedrockRuntime"/> instance.</summary>
68+
/// <param name="runtime">The runtime instance to be represented as an <see cref="IEmbeddingGenerator{TInput, TEmbedding}"/>.</param>
69+
/// <param name="defaultModelId">
70+
/// The default model ID to use when no model is specified in a request. If not specified,
71+
/// a model must be provided in the <see cref="EmbeddingGenerationOptions.ModelId"/> passed to <see cref="IEmbeddingGenerator{TInput, TEmbedding}.GenerateAsync"/>.
72+
/// </param>
73+
/// <param name="defaultModelDimensions">
74+
/// The default number of dimensions to request be generated. This will be overridden by a <see cref="EmbeddingGenerationOptions.Dimensions"/>
75+
/// if that is specified to a request. If neither is specified, the default for the model will be used.
76+
/// </param>
77+
/// <returns>An <see cref="IEmbeddingGenerator{TInput, TEmbedding}"/> instance representing the <see cref="IAmazonBedrockRuntime"/> instance.</returns>
78+
/// <exception cref="ArgumentNullException"><paramref name="runtime"/> is <see langword="null"/>.</exception>
79+
public static IEmbeddingGenerator<string, Embedding<float>> AsIEmbeddingGenerator(
80+
this IAmazonBedrockRuntime runtime, string? defaultModelId = null, int? defaultModelDimensions = null) =>
81+
runtime is not null ? new BedrockEmbeddingGenerator(runtime, defaultModelId, defaultModelDimensions) :
82+
throw new ArgumentNullException(nameof(runtime));
83+
84+
/// <summary>Gets an <see cref="IImageGenerator"/> for the specified <see cref="IAmazonBedrockRuntime"/> instance.</summary>
85+
/// <param name="runtime">The runtime instance to be represented as an <see cref="IImageGenerator"/>.</param>
86+
/// <param name="defaultModelId">
87+
/// The default model ID to use when no model is specified in a request. If not specified,
88+
/// a model must be provided in the <see cref="ImageGenerationOptions.ModelId"/> passed to <see cref="IImageGenerator.GenerateAsync"/>.
89+
/// </param>
90+
/// <returns>An <see cref="IImageGenerator"/> instance representing the <see cref="IAmazonBedrockRuntime"/> instance.</returns>
91+
/// <exception cref="ArgumentNullException"><paramref name="runtime"/> is <see langword="null"/>.</exception>
92+
[Experimental("MEAI001")]
93+
public static IImageGenerator AsIImageGenerator(
94+
this IAmazonBedrockRuntime runtime, string? defaultModelId = null) =>
95+
runtime is not null ? new BedrockImageGenerator(runtime, defaultModelId) :
96+
throw new ArgumentNullException(nameof(runtime));
97+
}

0 commit comments

Comments
 (0)