Skip to content

Commit cdbb953

Browse files
committed
Adding files.
1 parent c50f41f commit cdbb953

File tree

6 files changed

+418
-0
lines changed

6 files changed

+418
-0
lines changed
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2+
// SPDX-License-Identifier: Apache-2.0
3+
4+
namespace BedrockActions;
5+
6+
public class BedrockActionsWrapper
7+
{
8+
}

dotnetv4/Bedrock/BedrockExamples.sln

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,10 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Tests", "Tests", "{898AFE57
1111
EndProject
1212
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BedrockTests", "Tests\BedrockTests.csproj", "{5486426B-A8E8-4C6A-BEE2-83DD7CDB68A6}"
1313
EndProject
14+
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Scenarios", "Scenarios", "{A3F7526C-B026-497B-A9A5-D503BB53EF72}"
15+
EndProject
16+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ConverseToolScenario", "Scenarios\ConverseToolScenario\ConverseToolScenario.csproj", "{1CF238B1-BCA5-4615-9F43-36BC2D61E7C6}"
17+
EndProject
1418
Global
1519
GlobalSection(SolutionConfigurationPlatforms) = preSolution
1620
Debug|Any CPU = Debug|Any CPU
@@ -25,13 +29,18 @@ Global
2529
{5486426B-A8E8-4C6A-BEE2-83DD7CDB68A6}.Debug|Any CPU.Build.0 = Debug|Any CPU
2630
{5486426B-A8E8-4C6A-BEE2-83DD7CDB68A6}.Release|Any CPU.ActiveCfg = Release|Any CPU
2731
{5486426B-A8E8-4C6A-BEE2-83DD7CDB68A6}.Release|Any CPU.Build.0 = Release|Any CPU
32+
{1CF238B1-BCA5-4615-9F43-36BC2D61E7C6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
33+
{1CF238B1-BCA5-4615-9F43-36BC2D61E7C6}.Debug|Any CPU.Build.0 = Debug|Any CPU
34+
{1CF238B1-BCA5-4615-9F43-36BC2D61E7C6}.Release|Any CPU.ActiveCfg = Release|Any CPU
35+
{1CF238B1-BCA5-4615-9F43-36BC2D61E7C6}.Release|Any CPU.Build.0 = Release|Any CPU
2836
EndGlobalSection
2937
GlobalSection(SolutionProperties) = preSolution
3038
HideSolutionNode = FALSE
3139
EndGlobalSection
3240
GlobalSection(NestedProjects) = preSolution
3341
{C47E3B3E-0040-4CB6-AB92-EF4395C1EB83} = {0DD1E95E-9EF2-4E43-86B3-F636736BE054}
3442
{5486426B-A8E8-4C6A-BEE2-83DD7CDB68A6} = {898AFE57-24C6-4D79-81C2-614873B38F62}
43+
{1CF238B1-BCA5-4615-9F43-36BC2D61E7C6} = {A3F7526C-B026-497B-A9A5-D503BB53EF72}
3544
EndGlobalSection
3645
GlobalSection(ExtensibilityGlobals) = postSolution
3746
SolutionGuid = {3D82D9F6-BE3C-40F1-9224-B8E4D746FC2E}
Lines changed: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,104 @@
1+
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2+
// SPDX-License-Identifier: Apache-2.0
3+
4+
using Amazon.Bedrock;
5+
using BedrockActions;
6+
using Microsoft.Extensions.Configuration;
7+
using Microsoft.Extensions.DependencyInjection;
8+
using Microsoft.Extensions.Hosting;
9+
using Microsoft.Extensions.Logging;
10+
using Microsoft.Extensions.Logging.Console;
11+
using Microsoft.Extensions.Logging.Debug;
12+
13+
namespace ConverseToolScenario;
14+
15+
public static class ConverseToolScenario
16+
{
17+
/*
18+
Before running this .NET code example, set up your development environment, including your credentials.
19+
20+
This example demonstrates the use TODO
21+
*/
22+
23+
public static BedrockActionsWrapper _bedrockActionsWrapper = null!;
24+
public static IConfiguration _configuration = null!;
25+
public static string _resourcePrefix = null!;
26+
public static string _sourceBucketName = null!;
27+
public static string _destinationBucketName = null!;
28+
public static string _sampleObjectKey = null!;
29+
public static string _sampleObjectEtag = null!;
30+
public static bool _interactive = true;
31+
32+
33+
public static async Task Main(string[] args)
34+
{
35+
// Set up dependency injection for the Amazon service.
36+
using var host = Host.CreateDefaultBuilder(args)
37+
.ConfigureLogging(logging =>
38+
logging.AddFilter("System", LogLevel.Debug)
39+
.AddFilter<DebugLoggerProvider>("Microsoft", LogLevel.Information)
40+
.AddFilter<ConsoleLoggerProvider>("Microsoft", LogLevel.Trace))
41+
.ConfigureServices((_, services) =>
42+
services.AddAWSService<IAmazonBedrock>()
43+
.AddTransient<BedrockActionsWrapper>()
44+
)
45+
.Build();
46+
47+
_configuration = new ConfigurationBuilder()
48+
.SetBasePath(Directory.GetCurrentDirectory())
49+
.AddJsonFile("settings.json") // Load settings from .json file.
50+
.AddJsonFile("settings.local.json",
51+
true) // Optionally, load local settings.
52+
.Build();
53+
54+
ServicesSetup(host);
55+
56+
try
57+
{
58+
Console.WriteLine(new string('-', 80));
59+
Console.WriteLine("Welcome to the Amazon Bedrock Converse API with Tool Use Feature Scenario.");
60+
Console.WriteLine(new string('-', 80));
61+
ConfigurationSetup();
62+
63+
64+
//await DisplayDemoChoices(_sourceBucketName, _destinationBucketName, _sampleObjectKey, _sampleObjectEtag, 0);
65+
66+
Console.WriteLine(new string('-', 80));
67+
Console.WriteLine("Cleaning up resources.");
68+
Console.WriteLine(new string('-', 80));
69+
//await Cleanup(true);
70+
71+
Console.WriteLine(new string('-', 80));
72+
Console.WriteLine("Amazon Bedrock Converse API with Tool Use Feature Scenario is complete.");
73+
Console.WriteLine(new string('-', 80));
74+
}
75+
catch (Exception ex)
76+
{
77+
Console.WriteLine(new string('-', 80));
78+
Console.WriteLine($"There was a problem: {ex.Message}");
79+
//await CleanupScenario(_sourceBucketName, _destinationBucketName);
80+
Console.WriteLine(new string('-', 80));
81+
}
82+
}
83+
84+
/// <summary>
85+
/// Populate the services for use within the console application.
86+
/// </summary>
87+
/// <param name="host">The services host.</param>
88+
private static void ServicesSetup(IHost host)
89+
{
90+
_bedrockActionsWrapper = host.Services.GetRequiredService<BedrockActionsWrapper>();
91+
}
92+
93+
/// <summary>
94+
/// Any setup operations needed.
95+
/// </summary>
96+
public static void ConfigurationSetup()
97+
{
98+
_resourcePrefix = _configuration["resourcePrefix"] ?? "dotnet-example";
99+
100+
_sourceBucketName = _resourcePrefix + "-source";
101+
_destinationBucketName = _resourcePrefix + "-dest";
102+
_sampleObjectKey = _resourcePrefix + "-sample-object.txt";
103+
}
104+
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<PropertyGroup>
4+
<OutputType>Exe</OutputType>
5+
<TargetFramework>net8.0</TargetFramework>
6+
<ImplicitUsings>enable</ImplicitUsings>
7+
<Nullable>enable</Nullable>
8+
</PropertyGroup>
9+
10+
<ItemGroup>
11+
<PackageReference Include="AWSSDK.Extensions.NETCore.Setup" Version="3.7.301" />
12+
<PackageReference Include="Microsoft.Extensions.Configuration" Version="9.0.0" />
13+
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="9.0.0" />
14+
<PackageReference Include="Microsoft.Extensions.Hosting" Version="9.0.0" />
15+
</ItemGroup>
16+
17+
<ItemGroup>
18+
<ProjectReference Include="..\..\Actions\BedrockActions.csproj" />
19+
</ItemGroup>
20+
21+
</Project>
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
# Amazon S3 Conditional Requests Feature Scenario
2+
3+
## Overview
4+
5+
This example shows how to use AWS SDKs to work with Amazon Simple Storage Service (Amazon S3) conditional request features. The scenario demonstrates how to add preconditions to S3 operations, and how those operations will succeed or fail based on the conditional requests.
6+
7+
[Amazon S3 Conditional Requests](https://docs.aws.amazon.com/AmazonS3/latest/userguide/conditional-requests.html) are used to add preconditions to S3 read, copy, or write requests.
8+
9+
This scenario demonstrates the following steps and tasks:
10+
1. Create test buckets and objects.
11+
2. Use preconditions with S3 read and copy operations.
12+
3. Use preconditions with S3 write operations to prevent overwrites.
13+
4. Delete the objects and buckets.
14+
15+
### Resources
16+
17+
The scenario steps create the buckets and objects needed for the example. No additional resources are required.
18+
19+
## Implementations
20+
21+
This example is implemented in the following languages:
22+
23+
- [Python](../../python/example_code/s3/scenarios/conditional_requests/README.md)
24+
- [.NET](../../dotnetv3/S3/scenarios/S3ConditionalRequestsScenario/README.md)
25+
26+
## Additional reading
27+
28+
- [S3 Conditional Reads](https://docs.aws.amazon.com/AmazonS3/latest/userguide/conditional-reads.html)
29+
- [S3 Conditional Writes](https://docs.aws.amazon.com/AmazonS3/latest/userguide/conditional-writes.html)
30+
31+
---
32+
33+
Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. SPDX-License-Identifier: Apache-2.0

0 commit comments

Comments
 (0)