File tree 3 files changed +5
-14
lines changed
swift/example_code/bedrock-runtime/models/amazon-nova/amazon-nova-text
3 files changed +5
-14
lines changed Original file line number Diff line number Diff line change @@ -15,7 +15,6 @@ let package = Package(
15
15
] ,
16
16
dependencies: [
17
17
// Dependencies declare other packages that this package depends on.
18
- . package ( url: " https://github.com/apple/swift-argument-parser.git " , from: " 1.3.0 " ) ,
19
18
. package ( url: " https://github.com/awslabs/aws-sdk-swift " , from: " 1.2.61 " )
20
19
] ,
21
20
targets: [
@@ -25,15 +24,13 @@ let package = Package(
25
24
name: " Converse " ,
26
25
dependencies: [
27
26
. product( name: " AWSBedrockRuntime " , package : " aws-sdk-swift " ) ,
28
- . product( name: " ArgumentParser " , package : " swift-argument-parser " )
29
27
] ,
30
28
path: " Sources/Converse "
31
29
) ,
32
30
. executableTarget(
33
31
name: " ConverseStream " ,
34
32
dependencies: [
35
33
. product( name: " AWSBedrockRuntime " , package : " aws-sdk-swift " ) ,
36
- . product( name: " ArgumentParser " , package : " swift-argument-parser " )
37
34
] ,
38
35
path: " Sources/ConverseStream "
39
36
)
Original file line number Diff line number Diff line change 4
4
// snippet-start:[swift.example_code.bedrock-runtime.Converse_AmazonNovaText]
5
5
// An example demonstrating how to use the Conversation API to send a text message to Amazon Nova.
6
6
7
- import ArgumentParser
8
- import AWSClientRuntime
9
- import Foundation
10
7
import AWSBedrockRuntime
11
8
12
9
func converse( _ textPrompt: String ) async throws -> String {
@@ -50,11 +47,11 @@ func converse(_ textPrompt: String) async throws -> String {
50
47
}
51
48
}
52
49
50
+ // snippet-end:[swift.example_code.bedrock-runtime.Converse_AmazonNovaText]
51
+
53
52
do {
54
53
let reply = try await converse ( " Describe the purpose of a 'hello world' program in one line. " )
55
54
print ( reply)
56
55
} catch {
57
56
print ( " An error occured: \( error) " )
58
57
}
59
-
60
- // snippet-end:[swift.example_code.bedrock-runtime.Converse_AmazonNovaText]
Original file line number Diff line number Diff line change 4
4
// snippet-start:[swift.example_code.bedrock-runtime.ConverseStream_AmazonNovaText]
5
5
// An example demonstrating how to use the Conversation API to send a text message to Amazon Nova and print the response stream
6
6
7
- import ArgumentParser
8
- import AWSClientRuntime
9
- import Foundation
10
7
import AWSBedrockRuntime
11
8
12
9
func printConverseStream( _ textPrompt: String ) async throws {
13
10
14
11
// 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 " )
16
13
let client = BedrockRuntimeClient ( config: config)
17
14
18
15
// Set the model ID.
@@ -61,10 +58,10 @@ func printConverseStream(_ textPrompt: String) async throws {
61
58
}
62
59
}
63
60
61
+ // snippet-end:[swift.example_code.bedrock-runtime.ConverseStream_AmazonNovaText]
62
+
64
63
do {
65
64
try await printConverseStream ( " Describe the purpose of a 'hello world' program in two paragraphs. " )
66
65
} catch {
67
66
print ( " An error occured: \( error) " )
68
67
}
69
-
70
- // snippet-end:[swift.example_code.bedrock-runtime.ConverseStream_AmazonNovaText]
You can’t perform that action at this time.
0 commit comments