Skip to content

Commit a2b985d

Browse files
committed
Swift-format
1 parent cc7a36f commit a2b985d

File tree

7 files changed

+28
-25
lines changed

7 files changed

+28
-25
lines changed

Examples/retrieve/Package.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,4 +27,4 @@ let package = Package(
2727
]
2828
)
2929
]
30-
)
30+
)

Examples/retrieve/Sources/Retrieve.swift

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,16 +25,16 @@ struct Main {
2525
print("Error:\n\(error)")
2626
}
2727
}
28-
28+
2929
static func retrieve() async throws {
3030
var logger = Logger(label: "Retrieve")
3131
logger.logLevel = .debug
3232

3333
let bedrock = try await BedrockService(
3434
region: .uswest2,
3535
logger: logger
36-
// uncomment if you use SSO with AWS Identity Center
37-
// authentication: .sso
36+
// uncomment if you use SSO with AWS Identity Center
37+
// authentication: .sso
3838
)
3939

4040
let knowledgeBaseId = "EQ13XRVPLE"
@@ -54,15 +54,15 @@ struct Main {
5454
)
5555

5656
print("Retrieved \(response.results?.count ?? 0) results:")
57-
57+
5858
// Show best match using convenience function
5959
if let bestMatch = response.bestMatch() {
6060
print("\n--- Best Match (Score: \(bestMatch.score ?? 0)) ---")
6161
if let content = bestMatch.content?.text {
6262
print("Content: \(content)")
6363
}
6464
}
65-
65+
6666
// Show all results using convenience property
6767
// if let results = response.results {
6868
// for (index, result) in results.enumerated() {
@@ -79,4 +79,4 @@ struct Main {
7979
// }
8080
// }
8181
}
82-
}
82+
}

Sources/BedrockService/BedrockService+AgentRuntime.swift

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -48,10 +48,13 @@ extension BedrockService {
4848
retrievalQuery: String,
4949
numberOfResults: Int = 3
5050
) async throws -> RetrieveResult {
51-
logger.trace("Retrieving from knowledge base", metadata: [
52-
"knowledgeBaseId": .string(knowledgeBaseId),
53-
"numberOfResults": .stringConvertible(numberOfResults)
54-
])
51+
logger.trace(
52+
"Retrieving from knowledge base",
53+
metadata: [
54+
"knowledgeBaseId": .string(knowledgeBaseId),
55+
"numberOfResults": .stringConvertible(numberOfResults),
56+
]
57+
)
5558

5659
let input = RetrieveInput(
5760
knowledgeBaseId: knowledgeBaseId,
@@ -66,4 +69,4 @@ extension BedrockService {
6669
try handleCommonError(error, context: "retrieving from knowledge base")
6770
}
6871
}
69-
}
72+
}

Sources/BedrockService/BedrockService.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@
1414
//===----------------------------------------------------------------------===//
1515

1616
@preconcurrency import AWSBedrock
17-
@preconcurrency import AWSBedrockRuntime
1817
@preconcurrency import AWSBedrockAgentRuntime
18+
@preconcurrency import AWSBedrockRuntime
1919
import AWSClientRuntime
2020
import AWSSSOOIDC
2121
import AwsCommonRuntimeKit
@@ -112,7 +112,7 @@ public struct BedrockService: Sendable {
112112
metadata: ["authentication type": "\(authentication)"]
113113
)
114114
}
115-
115+
116116
self.logger.trace(
117117
"Initialized SwiftBedrock",
118118
metadata: ["region": .string(region.rawValue)]

Sources/BedrockService/Protocols/BedrockAgentRuntimeProtocol.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,4 +27,4 @@ public protocol BedrockAgentRuntimeProtocol: Sendable {
2727
func retrieve(input: RetrieveInput) async throws -> RetrieveOutput
2828
}
2929

30-
extension BedrockAgentRuntimeClient: @retroactive @unchecked Sendable, BedrockAgentRuntimeProtocol {}
30+
extension BedrockAgentRuntimeClient: @retroactive @unchecked Sendable, BedrockAgentRuntimeProtocol {}

Sources/BedrockService/Protocols/BedrockConfigProtocol.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@
1414
//===----------------------------------------------------------------------===//
1515

1616
import AWSBedrock
17-
import AWSBedrockRuntime
1817
import AWSBedrockAgentRuntime
18+
import AWSBedrockRuntime
1919
import ClientRuntime
2020
import SmithyHTTPAuthAPI
2121
import SmithyIdentity

Sources/BedrockService/RetrieveResult.swift

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -31,31 +31,31 @@ struct SerializableResult: Codable {
3131

3232
public struct RetrieveResult: Sendable {
3333
public let output: RetrieveOutput
34-
34+
3535
public init(_ output: RetrieveOutput) {
3636
self.output = output
3737
}
38-
38+
3939
public var results: [RAGRetrievalResult]? {
40-
return output.retrievalResults
40+
output.retrievalResults
4141
}
42-
42+
4343
public func bestMatch() -> RAGRetrievalResult? {
44-
return output.retrievalResults?.max { ($0.score ?? 0) < ($1.score ?? 0) }
44+
output.retrievalResults?.max { ($0.score ?? 0) < ($1.score ?? 0) }
4545
}
46-
46+
4747
public func toJSON() throws -> String {
4848
guard let results = output.retrievalResults else { return "[]" }
49-
49+
5050
let serializableResults = results.map { result in
5151
SerializableResult(
5252
content: result.content?.text,
5353
score: result.score,
5454
source: result.location?.s3Location?.uri
5555
)
5656
}
57-
57+
5858
let jsonData = try JSONEncoder().encode(serializableResults)
5959
return String(data: jsonData, encoding: .utf8) ?? "[]"
6060
}
61-
}
61+
}

0 commit comments

Comments
 (0)