File tree Expand file tree Collapse file tree
swift/example_code/bedrock-runtime/models/amazon-nova/amazon-nova-text Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -15,7 +15,6 @@ let package = Package(
1515 ] ,
1616 dependencies: [
1717 // Dependencies declare other packages that this package depends on.
18- . package ( url: " https://github.com/apple/swift-argument-parser.git " , from: " 1.3.0 " ) ,
1918 . package ( url: " https://github.com/awslabs/aws-sdk-swift " , from: " 1.2.61 " )
2019 ] ,
2120 targets: [
@@ -25,15 +24,13 @@ let package = Package(
2524 name: " Converse " ,
2625 dependencies: [
2726 . product( name: " AWSBedrockRuntime " , package : " aws-sdk-swift " ) ,
28- . product( name: " ArgumentParser " , package : " swift-argument-parser " )
2927 ] ,
3028 path: " Sources/Converse "
3129 ) ,
3230 . executableTarget(
3331 name: " ConverseStream " ,
3432 dependencies: [
3533 . product( name: " AWSBedrockRuntime " , package : " aws-sdk-swift " ) ,
36- . product( name: " ArgumentParser " , package : " swift-argument-parser " )
3734 ] ,
3835 path: " Sources/ConverseStream "
3936 )
Original file line number Diff line number Diff line change 44// snippet-start:[swift.example_code.bedrock-runtime.Converse_AmazonNovaText]
55// An example demonstrating how to use the Conversation API to send a text message to Amazon Nova.
66
7- import ArgumentParser
8- import AWSClientRuntime
9- import Foundation
107import AWSBedrockRuntime
118
129func converse( _ textPrompt: String ) async throws -> String {
@@ -50,11 +47,11 @@ func converse(_ textPrompt: String) async throws -> String {
5047 }
5148}
5249
50+ // snippet-end:[swift.example_code.bedrock-runtime.Converse_AmazonNovaText]
51+
5352do {
5453 let reply = try await converse ( " Describe the purpose of a 'hello world' program in one line. " )
5554 print ( reply)
5655} catch {
5756 print ( " An error occured: \( error) " )
5857}
59-
60- // snippet-end:[swift.example_code.bedrock-runtime.Converse_AmazonNovaText]
Original file line number Diff line number Diff line change 44// snippet-start:[swift.example_code.bedrock-runtime.ConverseStream_AmazonNovaText]
55// An example demonstrating how to use the Conversation API to send a text message to Amazon Nova and print the response stream
66
7- import ArgumentParser
8- import AWSClientRuntime
9- import Foundation
107import AWSBedrockRuntime
118
129func printConverseStream( _ textPrompt: String ) async throws {
1310
1411 // Create a Bedrock Runtime client in the AWS Region you want to use.
15- let config = try await BedrockRuntimeClient . BedrockRuntimeClientConfiguration ( region: " us-east-1 " )
12+ let config = try await BedrockRuntimeClient . BedrockRuntimeClientConfiguration ( region: " us-east-1 " )
1613 let client = BedrockRuntimeClient ( config: config)
1714
1815 // Set the model ID.
@@ -61,10 +58,10 @@ func printConverseStream(_ textPrompt: String) async throws {
6158 }
6259}
6360
61+ // snippet-end:[swift.example_code.bedrock-runtime.ConverseStream_AmazonNovaText]
62+
6463do {
6564 try await printConverseStream ( " Describe the purpose of a 'hello world' program in two paragraphs. " )
6665} catch {
6766 print ( " An error occured: \( error) " )
6867}
69-
70- // snippet-end:[swift.example_code.bedrock-runtime.ConverseStream_AmazonNovaText]
You can’t perform that action at this time.
0 commit comments