Skip to content

Commit b7fec15

Browse files
committed
fix typos in README
1 parent 75038ea commit b7fec15

File tree

1 file changed

+19
-20
lines changed

1 file changed

+19
-20
lines changed

swift-bedrock-library/README.md

Lines changed: 19 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
# BedrockService
1+
# Swift Bedrock Library
22

3-
This library is a work in progress, feel free to open an issue, but do not use it in your projects just yet.
3+
A tiny layer on top of the [AWS SDK for Swift](https://github.com/awslabs/aws-sdk-swift) for interacting with [Amazon Bedrock](https://docs.aws.amazon.com/bedrock/latest/userguide/what-is-bedrock.html) foundation models. This library provides a convenient way to access Amazon Bedrock's capabilities from Swift applications.
44

55
## Getting started with BedrockService
66

@@ -66,12 +66,11 @@ Use the `listModels()` function to test your set-up. This function will return a
6666
let models = try await bedrock.listModels()
6767
```
6868

69-
7069
## Chatting using the Converse or ConverseStream API
7170

7271
### Text prompt
7372

74-
To sent a text prompt to a model, first choose a model that supports converse, you can verify this by using the `hasConverseModality` function on the `BedrockModel`. Then use the model to create a `ConverseRequestBuilder`, add your prompt to it with the `.withPormpt` function. Use the builder to sent your request to the Converse API with the `converse` function. You can then easily print the reply and use it to create a new builder with the same model and inference parameters but with an updated history.
73+
To send a text prompt to a model, first choose a model that supports converse, you can verify this by using the `hasConverseModality` function on the `BedrockModel`. Then use the model to create a `ConverseRequestBuilder`, add your prompt to it with the `.withPrompt` function. Use the builder to send your request to the Converse API with the `converse` function. You can then easily print the reply and use it to create a new builder with the same model and inference parameters but with an updated history.
7574

7675
```swift
7776
let model: BedrockModel = .nova_lite
@@ -155,7 +154,7 @@ builder = try ConverseRequestBuilder(from: builder, with: assistantMessage)
155154

156155
### Vision
157156

158-
To sent an image to a model, first ensure the model suports vision. Next simply add the image to the `ConverseRequestBuilder` with the `withImage` function. The function can either take an `ImageBlock` object or the format and bytes to construct the object.
157+
To send an image to a model, first ensure the model supports vision. Next simply add the image to the `ConverseRequestBuilder` with the `withImage` function. The function can either take an `ImageBlock` object or the format and bytes to construct the object.
159158

160159

161160
```swift
@@ -205,7 +204,7 @@ To use streaming use the exact same `ConverseRequestBuilder`, but use the `conve
205204

206205
### Document
207206

208-
To sent an document to a model, first ensure the model suports document. Next simply add the image to the `ConverseRequestBuilder` with the `withDocument` function. The function can either take an `DocumentBlock` object or the name, format and bytes to construct the object.
207+
To send a document to a model, first ensure the model supports document. Next simply add the document to the `ConverseRequestBuilder` with the `withDocument` function. The function can either take a `DocumentBlock` object or the name, format and bytes to construct the object.
209208

210209
```swift
211210
let model: BedrockModel = .nova_lite
@@ -256,7 +255,7 @@ To use streaming use the exact same `ConverseRequestBuilder`, but use the `conve
256255

257256
### Tools
258257

259-
For tool usage, first ensure the model supports the use of tools. Next define at least one `Tool` and add it to the `ConverseRequestBuilder` with the `withTool` function (or the `withTools` function to add several tools at once). After sending a request the model could now sent back a `ToolUse` asking for specific information from a specific tool. Use this to sent the information back in a `ToolResult`, by using the `withToolResult` function. You will now receive a reply informed by the result from the tool.
258+
For tool usage, first ensure the model supports the use of tools. Next define at least one `Tool` and add it to the `ConverseRequestBuilder` with the `withTool` function (or the `withTools` function to add several tools at once). After sending a request the model could now send back a `ToolUse` asking for specific information from a specific tool. Use this to send the information back in a `ToolResult`, by using the `withToolResult` function. You will now receive a reply informed by the result from the tool.
260259

261260

262261
```swift
@@ -406,7 +405,7 @@ while true {
406405

407406
### Reasoning
408407

409-
To not only get a text reply but to also follow the models reasoning, enable reasoning by using the `withReasoning` and optionally set the maximum lenght of the reasoning with `withMaxReasoningTokens`. These functions can be combined using the `withReasoning(maxReasoningTokens: Int)` function.
408+
To not only get a text reply but to also follow the model's reasoning, enable reasoning by using the `withReasoning` and optionally set the maximum length of the reasoning with `withMaxReasoningTokens`. These functions can be combined using the `withReasoning(maxReasoningTokens: Int)` function.
410409

411410
```swift
412411
let model: BedrockModel = .claudev3_7_sonnet
@@ -433,7 +432,7 @@ if let reasoning = try? reply.getReasoningBlock() {
433432
print("\nAssistant: \(reply)")
434433
```
435434

436-
To combine reasoning and streaming, use the same `ConverseRequestBuilder`, but use the `converseStream` function instead of the `converse`function. A `ContentSegment` can then contain `reasoning`.
435+
To combine reasoning and streaming, use the same `ConverseRequestBuilder`, but use the `converseStream` function instead of the `converse` function. A `ContentSegment` can then contain `reasoning`.
437436

438437
```swift
439438
let model: BedrockModel = .claudev3_7_sonnet
@@ -587,7 +586,7 @@ let nonExistent: String? = json["nonExistentKey"]
587586
print(nonExistent == nil) // Output: true
588587
```
589588

590-
Note that the subscript methods is also able to handle nested objects.
589+
Note that the subscript method is also able to handle nested objects.
591590

592591
```swift
593592
let json = JSON([
@@ -651,7 +650,7 @@ let imageGeneration = try await bedrock.generateImage(
651650
Note that the minimum, maximum and default values for each parameter are model specific and defined when the BedrockModel is created. Some parameters might not be supported by certain models.
652651

653652
## Generating image variations using the InvokeModel API
654-
Choose a BedrockModel that supports image variations - you can verify this using the `hasImageVariationModality` and the `hasImageVariationModality` function. The `generateImageVariation` function allows you to create variations of an existing image with these parameters:
653+
Choose a BedrockModel that supports image variations - you can verify this using the `hasImageModality` and the `hasImageVariationModality` function. The `generateImageVariation` function allows you to create variations of an existing image with these parameters:
655654

656655
- `images`: The base64-encoded source images used to create variations from
657656
- `negativePrompt`: Text describing what to avoid in the generated image
@@ -700,15 +699,15 @@ Note that the minimum, maximum and default values for each parameter are model s
700699

701700
## Generating text using the InvokeModel API
702701

703-
Choose a BedrockModel that supports text generation, you can verify this using the `hasTextModality` function. when calling the `completeText` function you can provide some inference parameters:
702+
Choose a BedrockModel that supports text generation, you can verify this using the `hasTextModality` function. When calling the `completeText` function you can provide some inference parameters:
704703

705704
- `maxTokens`: The maximum amount of tokens that the model is allowed to return
706705
- `temperature`: Controls the randomness of the model's output
707706
- `topP`: Nucleus sampling, this parameter controls the cumulative probability threshold for token selection
708707
- `topK`: Limits the number of tokens the model considers for each step of text generation to the K most likely ones
709708
- `stopSequences`: An array of strings that will cause the model to stop generating further text when encountered
710709

711-
The function returns a `TextCompletion` object containg the generated text.
710+
The function returns a `TextCompletion` object containing the generated text.
712711

713712
```swift
714713
let model: BedrockModel = .nova_micro
@@ -745,7 +744,7 @@ Note that the minimum, maximum and default values for each parameter are model s
745744

746745
### Converse
747746

748-
To add a new model that only needs the ConverseModality, simply use the `StandardConverse` and add the correct [inferece parameters](https://docs.aws.amazon.com/bedrock/latest/userguide/model-parameters.html) and [supported converse features](https://docs.aws.amazon.com/bedrock/latest/userguide/conversation-inference-supported-models-features.html).
747+
To add a new model that only needs the ConverseModality, simply use the `StandardConverse` and add the correct [inference parameters](https://docs.aws.amazon.com/bedrock/latest/userguide/model-parameters.html) and [supported converse features](https://docs.aws.amazon.com/bedrock/latest/userguide/conversation-inference-supported-models-features.html).
749748

750749
```swift
751750
extension BedrockModel {
@@ -790,7 +789,7 @@ struct ModelFamilyModality: TextModality, ConverseModality {
790789

791790
### Text
792791

793-
If you need to add a model from a model family that is not supported at all byt the library, follow these steps:
792+
If you need to add a model from a model family that is not supported at all by the library, follow these steps:
794793

795794
#### Step 1: Create family-specific request and response struct
796795

@@ -847,7 +846,7 @@ struct LlamaResponseBody: ContainsTextCompletion {
847846
}
848847
```
849848

850-
#### Step 2: Create the the Modality
849+
#### Step 2: Create the Modality
851850

852851
For a text generation create a struct conforming to TextModality. Use the request body and response body you created in [the previous step](#step-1-create-family-specific-request-and-response-struct). Make sure to check for model(family) specific rules or parameters that are not supported here.
853852

@@ -896,7 +895,7 @@ struct LlamaText: TextModality {
896895

897896
#### Step 3: Create BedrockModel instance
898897

899-
You can now create instances for any of the models that follow the request and response structure you defined. Make sure to check the allowed and default values for the inference parameters, especially if some parameters are not supported buy the model. Know that these parameters may differ significantly for model from the same family.
898+
You can now create instances for any of the models that follow the request and response structure you defined. Make sure to check the allowed and default values for the inference parameters, especially if some parameters are not supported by the model. Know that these parameters may differ significantly for models from the same family.
900899

901900
```swift
902901
extension BedrockModel {
@@ -919,7 +918,7 @@ extension BedrockModel {
919918

920919
### Image
921920

922-
To add an image generation model from a model family that is not supported at all byt the library, the steps are much alike to the text completion models.
921+
To add an image generation model from a model family that is not supported at all by the library, the steps are much alike to the text completion models.
923922

924923
#### Step 1: Create family-specific request and response struct
925924

@@ -993,7 +992,7 @@ public struct AmazonImageResponseBody: ContainsImageGeneration {
993992
}
994993
```
995994

996-
#### Step 2: Create the the Modality
995+
#### Step 2: Create the Modality
997996

998997
Determine the exact functionality and make sure to comply to the correct modality protocol. In this case we will use `TextToImageModality`.
999998
Create a struct conforming to `ImageModality` and the specific functionality protocol. Use the request body and response body you created in [the previous step](#step-1-create-family-specific-request-and-response-struct). Make sure to check for model(family) specific rules or parameters that are not supported here.
@@ -1054,7 +1053,7 @@ struct AmazonImage: ImageModality, TextToImageModality {
10541053

10551054
#### Step 3: Create BedrockModel instance
10561055

1057-
You can now create instances for any of the models that follow the request and response structure you defined. Make sure to check the allowed and default values for the inference parameters, especially if some parameters are not supported buy the model. Know that these parameters may differ significantly for model from the same family.
1056+
You can now create instances for any of the models that follow the request and response structure you defined. Make sure to check the allowed and default values for the inference parameters, especially if some parameters are not supported by the model. Know that these parameters may differ significantly for models from the same family.
10581057

10591058
```swift
10601059
extension BedrockModel {

0 commit comments

Comments
 (0)