From e0211e48ab6ecb2f7bac4c0bcf20297778ba52e4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Stormacq?= Date: Thu, 23 Oct 2025 20:47:41 +0200 Subject: [PATCH 01/10] add basic support for agentruntime --- Examples/retrieve/.gitignore | 8 ++ Examples/retrieve/Package.swift | 30 ++++ Examples/retrieve/Sources/Retrieve.swift | 82 +++++++++++ Package.swift | 1 + .../BedrockService+AgentRuntime.swift | 69 +++++++++ Sources/BedrockService/BedrockService.swift | 20 +++ .../Docs.docc/BedrockService.md | 1 + Sources/BedrockService/Docs.docc/Retrieval.md | 133 ++++++++++++++++++ .../BedrockAgentRuntimeProtocol.swift | 30 ++++ .../Protocols/BedrockConfigProtocol.swift | 4 + Sources/BedrockService/RetrieveResult.swift | 61 ++++++++ 11 files changed, 439 insertions(+) create mode 100644 Examples/retrieve/.gitignore create mode 100644 Examples/retrieve/Package.swift create mode 100644 Examples/retrieve/Sources/Retrieve.swift create mode 100644 Sources/BedrockService/BedrockService+AgentRuntime.swift create mode 100644 Sources/BedrockService/Docs.docc/Retrieval.md create mode 100644 Sources/BedrockService/Protocols/BedrockAgentRuntimeProtocol.swift create mode 100644 Sources/BedrockService/RetrieveResult.swift diff --git a/Examples/retrieve/.gitignore b/Examples/retrieve/.gitignore new file mode 100644 index 00000000..85146e6e --- /dev/null +++ b/Examples/retrieve/.gitignore @@ -0,0 +1,8 @@ +.DS_Store +/.build +/Packages +xcuserdata/ +DerivedData/ +.swiftpm/configuration/registries.json +.swiftpm/xcode/package.xcworkspace/contents.xcworkspacedata +.netrc \ No newline at end of file diff --git a/Examples/retrieve/Package.swift b/Examples/retrieve/Package.swift new file mode 100644 index 00000000..f458210b --- /dev/null +++ b/Examples/retrieve/Package.swift @@ -0,0 +1,30 @@ +// swift-tools-version: 6.0 +// The swift-tools-version declares the minimum version of Swift required to build this package. + +import PackageDescription + +let package = Package( + name: "Retrieve", + platforms: [.macOS(.v15), .iOS(.v18), .tvOS(.v18)], + products: [ + .executable(name: "Retrieve", targets: ["Retrieve"]) + ], + dependencies: [ + // for production use, uncomment the following line + // .package(url: "https://github.com/build-on-aws/swift-bedrock-library.git", branch: "main"), + + // for local development, use the following line + .package(name: "swift-bedrock-library", path: "../.."), + + .package(url: "https://github.com/apple/swift-log.git", from: "1.5.0"), + ], + targets: [ + .executableTarget( + name: "Retrieve", + dependencies: [ + .product(name: "BedrockService", package: "swift-bedrock-library"), + .product(name: "Logging", package: "swift-log"), + ] + ) + ] +) \ No newline at end of file diff --git a/Examples/retrieve/Sources/Retrieve.swift b/Examples/retrieve/Sources/Retrieve.swift new file mode 100644 index 00000000..0161edf2 --- /dev/null +++ b/Examples/retrieve/Sources/Retrieve.swift @@ -0,0 +1,82 @@ +//===----------------------------------------------------------------------===// +// +// This source file is part of the Swift Bedrock Library open source project +// +// Copyright (c) 2025 Amazon.com, Inc. or its affiliates +// and the Swift Bedrock Library project authors +// Licensed under Apache License v2.0 +// +// See LICENSE.txt for license information +// See CONTRIBUTORS.txt for the list of Swift Bedrock Library project authors +// +// SPDX-License-Identifier: Apache-2.0 +// +//===----------------------------------------------------------------------===// + +import BedrockService +import Logging + +@main +struct Main { + static func main() async throws { + do { + try await Main.retrieve() + } catch { + print("Error:\n\(error)") + } + } + + static func retrieve() async throws { + var logger = Logger(label: "Retrieve") + logger.logLevel = .debug + + let bedrock = try await BedrockService( + region: .uswest2, + logger: logger + // uncomment if you use SSO with AWS Identity Center + // authentication: .sso + ) + + let knowledgeBaseId = "EQ13XRVPLE" + let query = "should I write open source or open-source" + let numberOfResults = 3 + + print("Retrieving from knowledge base...") + print("Knowledge Base ID: \(knowledgeBaseId)") + print("Query: \(query)") + print("Number of results: \(numberOfResults)") + print() + + let response = try await bedrock.retrieve( + knowledgeBaseId: knowledgeBaseId, + retrievalQuery: query, + numberOfResults: numberOfResults + ) + + print("Retrieved \(response.results?.count ?? 0) results:") + + // Show best match using convenience function + if let bestMatch = response.bestMatch() { + print("\n--- Best Match (Score: \(bestMatch.score ?? 0)) ---") + if let content = bestMatch.content?.text { + print("Content: \(content)") + } + } + + // Show all results using convenience property + // if let results = response.results { + // for (index, result) in results.enumerated() { + // print("\n--- Result \(index + 1) ---") + // if let content = result.content?.text { + // print("Content: \(content)") + // } + // if let score = result.score { + // print("Score: \(score)") + // } + // if let location = result.location?.s3Location { + // print("Source: s3://\(location.uri ?? "unknown")") + // } + // } + // } + } +} \ No newline at end of file diff --git a/Package.swift b/Package.swift index 35059e4c..e54c2f02 100644 --- a/Package.swift +++ b/Package.swift @@ -23,6 +23,7 @@ let package = Package( .product(name: "AWSClientRuntime", package: "aws-sdk-swift"), .product(name: "AWSBedrock", package: "aws-sdk-swift"), .product(name: "AWSBedrockRuntime", package: "aws-sdk-swift"), + .product(name: "AWSBedrockAgentRuntime", package: "aws-sdk-swift"), .product(name: "AWSSSOOIDC", package: "aws-sdk-swift"), .product(name: "Smithy", package: "smithy-swift"), .product(name: "Logging", package: "swift-log"), diff --git a/Sources/BedrockService/BedrockService+AgentRuntime.swift b/Sources/BedrockService/BedrockService+AgentRuntime.swift new file mode 100644 index 00000000..2ea14ca1 --- /dev/null +++ b/Sources/BedrockService/BedrockService+AgentRuntime.swift @@ -0,0 +1,69 @@ +//===----------------------------------------------------------------------===// +// +// This source file is part of the Swift Bedrock Library open source project +// +// Copyright (c) 2025 Amazon.com, Inc. or its affiliates +// and the Swift Bedrock Library project authors +// Licensed under Apache License v2.0 +// +// See LICENSE.txt for license information +// See CONTRIBUTORS.txt for the list of Swift Bedrock Library project authors +// +// SPDX-License-Identifier: Apache-2.0 +// +//===----------------------------------------------------------------------===// + +@preconcurrency import AWSBedrockAgentRuntime +import Logging + +extension BedrockService { + /// Creates a BedrockAgentRuntimeClient + /// - Parameters: + /// - region: The AWS region to configure the client for + /// - authentication: The authentication type to use + /// - logger: Logger instance + /// - Returns: Configured BedrockAgentRuntimeProtocol instance + /// - Throws: Error if client creation fails + internal static func createBedrockAgentRuntimeClient( + region: Region, + authentication: BedrockAuthentication, + logger: Logging.Logger + ) async throws -> BedrockAgentRuntimeClient { + let config: BedrockAgentRuntimeClient.BedrockAgentRuntimeClientConfiguration = try await prepareConfig( + initialConfig: BedrockAgentRuntimeClient.BedrockAgentRuntimeClientConfiguration(region: region.rawValue), + authentication: authentication, + logger: logger + ) + return BedrockAgentRuntimeClient(config: config) + } + /// Retrieves information from a knowledge base + /// - Parameters: + /// - knowledgeBaseId: The unique identifier of the knowledge base to query + /// - retrievalQuery: The query to search for in the knowledge base + /// - numberOfResults: The number of results to return (optional, defaults to 3) + /// - Returns: RetrieveResult containing the retrieved results + /// - Throws: BedrockLibraryError or other errors from the underlying service + public func retrieve( + knowledgeBaseId: String, + retrievalQuery: String, + numberOfResults: Int = 3 + ) async throws -> RetrieveResult { + logger.trace("Retrieving from knowledge base", metadata: [ + "knowledgeBaseId": .string(knowledgeBaseId), + "numberOfResults": .stringConvertible(numberOfResults) + ]) + + let input = RetrieveInput( + knowledgeBaseId: knowledgeBaseId, + retrievalQuery: BedrockAgentRuntimeClientTypes.KnowledgeBaseQuery(text: retrievalQuery) + ) + + do { + let response = try await bedrockAgentRuntimeClient.retrieve(input: input) + logger.trace("Successfully retrieved from knowledge base") + return RetrieveResult(response) + } catch { + try handleCommonError(error, context: "retrieving from knowledge base") + } + } +} \ No newline at end of file diff --git a/Sources/BedrockService/BedrockService.swift b/Sources/BedrockService/BedrockService.swift index 986b8a1d..030013c3 100644 --- a/Sources/BedrockService/BedrockService.swift +++ b/Sources/BedrockService/BedrockService.swift @@ -15,6 +15,7 @@ @preconcurrency import AWSBedrock @preconcurrency import AWSBedrockRuntime +@preconcurrency import AWSBedrockAgentRuntime import AWSClientRuntime import AWSSSOOIDC import AwsCommonRuntimeKit @@ -38,6 +39,7 @@ public struct BedrockService: Sendable { package let logger: Logging.Logger package let bedrockClient: BedrockClientProtocol package let bedrockRuntimeClient: BedrockRuntimeClientProtocol + package let bedrockAgentRuntimeClient: BedrockAgentRuntimeProtocol // MARK: - Initialization @@ -47,6 +49,7 @@ public struct BedrockService: Sendable { /// - logger: Optional custom logger instance /// - bedrockClient: Optional custom Bedrock client /// - bedrockRuntimeClient: Optional custom Bedrock Runtime client + /// - bedrockAgentRuntimeClient: Optional custom Bedrock Agent Runtime client /// - authentication: The authentication type to use (defaults to .default) /// - Throws: Error if client initialization fails public init( @@ -54,6 +57,7 @@ public struct BedrockService: Sendable { logger: Logging.Logger? = nil, bedrockClient: BedrockClientProtocol? = nil, bedrockRuntimeClient: BedrockRuntimeClientProtocol? = nil, + bedrockAgentRuntimeClient: BedrockAgentRuntimeProtocol? = nil, authentication: BedrockAuthentication = .default ) async throws { self.logger = logger ?? BedrockService.createLogger("bedrock.service") @@ -93,6 +97,22 @@ public struct BedrockService: Sendable { metadata: ["authentication type": "\(authentication)"] ) } + if bedrockAgentRuntimeClient != nil { + self.logger.trace("Using supplied bedrockAgentRuntimeClient") + self.bedrockAgentRuntimeClient = bedrockAgentRuntimeClient! + } else { + self.logger.trace("Creating bedrockAgentRuntimeClient") + self.bedrockAgentRuntimeClient = try await BedrockService.createBedrockAgentRuntimeClient( + region: region, + authentication: authentication, + logger: self.logger + ) + self.logger.trace( + "Created bedrockAgentRuntimeClient", + metadata: ["authentication type": "\(authentication)"] + ) + } + self.logger.trace( "Initialized SwiftBedrock", metadata: ["region": .string(region.rawValue)] diff --git a/Sources/BedrockService/Docs.docc/BedrockService.md b/Sources/BedrockService/Docs.docc/BedrockService.md index 7b37610c..be41c874 100644 --- a/Sources/BedrockService/Docs.docc/BedrockService.md +++ b/Sources/BedrockService/Docs.docc/BedrockService.md @@ -34,6 +34,7 @@ BedrockService is a lightweight layer on top of the AWS SDK for Swift that provi - - - +- ### Extending the Library diff --git a/Sources/BedrockService/Docs.docc/Retrieval.md b/Sources/BedrockService/Docs.docc/Retrieval.md new file mode 100644 index 00000000..52ad6bda --- /dev/null +++ b/Sources/BedrockService/Docs.docc/Retrieval.md @@ -0,0 +1,133 @@ +# Knowledge Base Retrieval + +Retrieve information from Amazon Bedrock knowledge bases for RAG applications + +## Overview + +The Knowledge Base Retrieval feature allows you to query Amazon Bedrock knowledge bases to retrieve relevant information for Retrieval-Augmented Generation (RAG) applications. This enables you to ground your AI responses with specific, up-to-date information from your own data sources. + +## Basic Retrieval + +Retrieve information from a knowledge base: + +```swift +let result = try await bedrock.retrieve( + knowledgeBaseId: "your-knowledge-base-id", + retrievalQuery: "What is the company policy on remote work?" +) + +// Get the best matching result +if let bestMatch = result.bestMatch() { + print("Best match: \(bestMatch.content?.text ?? "No content")") + print("Relevance score: \(bestMatch.score ?? 0)") +} + +// Access all results +if let allResults = result.results { + for (index, result) in allResults.enumerated() { + print("Result \(index + 1): \(result.content?.text ?? "No content")") + } +} +``` + +## Controlling Results + +Specify the number of results to retrieve: + +```swift +let result = try await bedrock.retrieve( + knowledgeBaseId: "your-knowledge-base-id", + retrievalQuery: "company benefits", + numberOfResults: 5 +) +``` + +## Working with Results + +The `RetrieveResult` wrapper provides convenient access to the retrieved information: + +```swift +let result = try await bedrock.retrieve( + knowledgeBaseId: "kb-123", + retrievalQuery: "product specifications" +) + +// Get the highest-scoring result +let bestMatch = result.bestMatch() + +// Access all results with scores and metadata +for retrievalResult in result.results ?? [] { + if let content = retrievalResult.content?.text { + print("Content: \(content)") + } + + if let score = retrievalResult.score { + print("Relevance Score: \(score)") + } + + if let source = retrievalResult.location?.s3Location?.uri { + print("Source: \(source)") + } +} +``` + +## JSON Export for LLM Context + +Export results as JSON to pass to language models: + +```swift +let result = try await bedrock.retrieve( + knowledgeBaseId: "kb-123", + retrievalQuery: "user documentation" +) + +// Convert to JSON for LLM context +let jsonContext = try result.toJSON() + +// Use in a conversation +let builder = try ConverseRequestBuilder(with: .nova_lite) + .withSystemPrompts(["Use this context to answer questions: \(jsonContext)"]) + .withPrompt("How do I reset my password?") + +let reply = try await bedrock.converse(with: builder) +``` + +## RAG Pattern Example + +Combine retrieval with conversation for a complete RAG implementation: + +```swift +func answerWithContext(question: String, knowledgeBaseId: String) async throws -> String { + // 1. Retrieve relevant information + let retrievalResult = try await bedrock.retrieve( + knowledgeBaseId: knowledgeBaseId, + retrievalQuery: question, + numberOfResults: 3 + ) + + // 2. Prepare context from results + let context = try retrievalResult.toJSON() + + // 3. Generate answer using retrieved context + let builder = try ConverseRequestBuilder(with: .nova_lite) + .withSystemPrompts([ + "Answer the user's question using only the provided context.", + "Context: \(context)" + ]) + .withPrompt(question) + + let reply = try await bedrock.converse(with: builder) + return reply +} + +// Usage +let answer = try await answerWithContext( + question: "What are the system requirements?", + knowledgeBaseId: "your-kb-id" +) +``` + +## See Also + +- +- \ No newline at end of file diff --git a/Sources/BedrockService/Protocols/BedrockAgentRuntimeProtocol.swift b/Sources/BedrockService/Protocols/BedrockAgentRuntimeProtocol.swift new file mode 100644 index 00000000..88659e03 --- /dev/null +++ b/Sources/BedrockService/Protocols/BedrockAgentRuntimeProtocol.swift @@ -0,0 +1,30 @@ +//===----------------------------------------------------------------------===// +// +// This source file is part of the Swift Bedrock Library open source project +// +// Copyright (c) 2025 Amazon.com, Inc. or its affiliates +// and the Swift Bedrock Library project authors +// Licensed under Apache License v2.0 +// +// See LICENSE.txt for license information +// See CONTRIBUTORS.txt for the list of Swift Bedrock Library project authors +// +// SPDX-License-Identifier: Apache-2.0 +// +//===----------------------------------------------------------------------===// + +@preconcurrency import AWSBedrockAgentRuntime +import AWSClientRuntime + +#if canImport(FoundationEssentials) +import FoundationEssentials +#else +import Foundation +#endif + +// Protocol allows writing mocks for unit tests +public protocol BedrockAgentRuntimeProtocol: Sendable { + func retrieve(input: RetrieveInput) async throws -> RetrieveOutput +} + +extension BedrockAgentRuntimeClient: @retroactive @unchecked Sendable, BedrockAgentRuntimeProtocol {} \ No newline at end of file diff --git a/Sources/BedrockService/Protocols/BedrockConfigProtocol.swift b/Sources/BedrockService/Protocols/BedrockConfigProtocol.swift index cc0e5b41..355c176b 100644 --- a/Sources/BedrockService/Protocols/BedrockConfigProtocol.swift +++ b/Sources/BedrockService/Protocols/BedrockConfigProtocol.swift @@ -15,6 +15,7 @@ import AWSBedrock import AWSBedrockRuntime +import AWSBedrockAgentRuntime import ClientRuntime import SmithyHTTPAuthAPI import SmithyIdentity @@ -38,3 +39,6 @@ extension BedrockClient.BedrockClientConfiguration: @retroactive @unchecked Send extension BedrockRuntimeClient.BedrockRuntimeClientConfiguration: @retroactive @unchecked Sendable, BedrockConfigProtocol {} +extension BedrockAgentRuntimeClient.BedrockAgentRuntimeClientConfiguration: @retroactive @unchecked Sendable, + BedrockConfigProtocol +{} diff --git a/Sources/BedrockService/RetrieveResult.swift b/Sources/BedrockService/RetrieveResult.swift new file mode 100644 index 00000000..690abaf0 --- /dev/null +++ b/Sources/BedrockService/RetrieveResult.swift @@ -0,0 +1,61 @@ +//===----------------------------------------------------------------------===// +// +// This source file is part of the Swift Bedrock Library open source project +// +// Copyright (c) 2025 Amazon.com, Inc. or its affiliates +// and the Swift Bedrock Library project authors +// Licensed under Apache License v2.0 +// +// See LICENSE.txt for license information +// See CONTRIBUTORS.txt for the list of Swift Bedrock Library project authors +// +// SPDX-License-Identifier: Apache-2.0 +// +//===----------------------------------------------------------------------===// + +@preconcurrency import AWSBedrockAgentRuntime + +#if canImport(FoundationEssentials) +import FoundationEssentials +#else +import Foundation +#endif + +public typealias RAGRetrievalResult = BedrockAgentRuntimeClientTypes.KnowledgeBaseRetrievalResult + +struct SerializableResult: Codable { + let content: String? + let score: Double? + let source: String? +} + +public struct RetrieveResult: Sendable { + public let output: RetrieveOutput + + public init(_ output: RetrieveOutput) { + self.output = output + } + + public var results: [RAGRetrievalResult]? { + return output.retrievalResults + } + + public func bestMatch() -> RAGRetrievalResult? { + return output.retrievalResults?.max { ($0.score ?? 0) < ($1.score ?? 0) } + } + + public func toJSON() throws -> String { + guard let results = output.retrievalResults else { return "[]" } + + let serializableResults = results.map { result in + SerializableResult( + content: result.content?.text, + score: result.score, + source: result.location?.s3Location?.uri + ) + } + + let jsonData = try JSONEncoder().encode(serializableResults) + return String(data: jsonData, encoding: .utf8) ?? "[]" + } +} \ No newline at end of file From cc7a36f5237a1ec7767e7231d49de15e831b74ac Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Stormacq?= Date: Thu, 23 Oct 2025 20:51:13 +0200 Subject: [PATCH 02/10] Add retrieve example to the CI --- .github/workflows/pull_request.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/pull_request.yml b/.github/workflows/pull_request.yml index 9e1978d6..d5b0e558 100644 --- a/.github/workflows/pull_request.yml +++ b/.github/workflows/pull_request.yml @@ -91,7 +91,7 @@ jobs: # We pass the list of examples here, but we can't pass an array as argument # Instead, we pass a String with a valid JSON array. # The workaround is mentioned here https://github.com/orgs/community/discussions/11692 - examples: "[ 'api-key', 'converse', 'converse-stream', 'embeddings', 'openai', 'text_chat' ]" + examples: "[ 'api-key', 'converse', 'converse-stream', 'embeddings', 'openai', 'retrieve', 'text_chat' ]" swift-6-language-mode: name: Swift 6 Language Mode From a2b985d80d7737a5a0937e21dc8e04d5d966cf60 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Stormacq?= Date: Thu, 23 Oct 2025 20:51:34 +0200 Subject: [PATCH 03/10] Swift-format --- Examples/retrieve/Package.swift | 2 +- Examples/retrieve/Sources/Retrieve.swift | 12 ++++++------ .../BedrockService+AgentRuntime.swift | 13 ++++++++----- Sources/BedrockService/BedrockService.swift | 4 ++-- .../BedrockAgentRuntimeProtocol.swift | 2 +- .../Protocols/BedrockConfigProtocol.swift | 2 +- Sources/BedrockService/RetrieveResult.swift | 18 +++++++++--------- 7 files changed, 28 insertions(+), 25 deletions(-) diff --git a/Examples/retrieve/Package.swift b/Examples/retrieve/Package.swift index f458210b..516032fd 100644 --- a/Examples/retrieve/Package.swift +++ b/Examples/retrieve/Package.swift @@ -27,4 +27,4 @@ let package = Package( ] ) ] -) \ No newline at end of file +) diff --git a/Examples/retrieve/Sources/Retrieve.swift b/Examples/retrieve/Sources/Retrieve.swift index 0161edf2..a20968db 100644 --- a/Examples/retrieve/Sources/Retrieve.swift +++ b/Examples/retrieve/Sources/Retrieve.swift @@ -25,7 +25,7 @@ struct Main { print("Error:\n\(error)") } } - + static func retrieve() async throws { var logger = Logger(label: "Retrieve") logger.logLevel = .debug @@ -33,8 +33,8 @@ struct Main { let bedrock = try await BedrockService( region: .uswest2, logger: logger - // uncomment if you use SSO with AWS Identity Center - // authentication: .sso + // uncomment if you use SSO with AWS Identity Center + // authentication: .sso ) let knowledgeBaseId = "EQ13XRVPLE" @@ -54,7 +54,7 @@ struct Main { ) print("Retrieved \(response.results?.count ?? 0) results:") - + // Show best match using convenience function if let bestMatch = response.bestMatch() { print("\n--- Best Match (Score: \(bestMatch.score ?? 0)) ---") @@ -62,7 +62,7 @@ struct Main { print("Content: \(content)") } } - + // Show all results using convenience property // if let results = response.results { // for (index, result) in results.enumerated() { @@ -79,4 +79,4 @@ struct Main { // } // } } -} \ No newline at end of file +} diff --git a/Sources/BedrockService/BedrockService+AgentRuntime.swift b/Sources/BedrockService/BedrockService+AgentRuntime.swift index 2ea14ca1..f072acba 100644 --- a/Sources/BedrockService/BedrockService+AgentRuntime.swift +++ b/Sources/BedrockService/BedrockService+AgentRuntime.swift @@ -48,10 +48,13 @@ extension BedrockService { retrievalQuery: String, numberOfResults: Int = 3 ) async throws -> RetrieveResult { - logger.trace("Retrieving from knowledge base", metadata: [ - "knowledgeBaseId": .string(knowledgeBaseId), - "numberOfResults": .stringConvertible(numberOfResults) - ]) + logger.trace( + "Retrieving from knowledge base", + metadata: [ + "knowledgeBaseId": .string(knowledgeBaseId), + "numberOfResults": .stringConvertible(numberOfResults), + ] + ) let input = RetrieveInput( knowledgeBaseId: knowledgeBaseId, @@ -66,4 +69,4 @@ extension BedrockService { try handleCommonError(error, context: "retrieving from knowledge base") } } -} \ No newline at end of file +} diff --git a/Sources/BedrockService/BedrockService.swift b/Sources/BedrockService/BedrockService.swift index 030013c3..11e8e1d1 100644 --- a/Sources/BedrockService/BedrockService.swift +++ b/Sources/BedrockService/BedrockService.swift @@ -14,8 +14,8 @@ //===----------------------------------------------------------------------===// @preconcurrency import AWSBedrock -@preconcurrency import AWSBedrockRuntime @preconcurrency import AWSBedrockAgentRuntime +@preconcurrency import AWSBedrockRuntime import AWSClientRuntime import AWSSSOOIDC import AwsCommonRuntimeKit @@ -112,7 +112,7 @@ public struct BedrockService: Sendable { metadata: ["authentication type": "\(authentication)"] ) } - + self.logger.trace( "Initialized SwiftBedrock", metadata: ["region": .string(region.rawValue)] diff --git a/Sources/BedrockService/Protocols/BedrockAgentRuntimeProtocol.swift b/Sources/BedrockService/Protocols/BedrockAgentRuntimeProtocol.swift index 88659e03..1c19eb8e 100644 --- a/Sources/BedrockService/Protocols/BedrockAgentRuntimeProtocol.swift +++ b/Sources/BedrockService/Protocols/BedrockAgentRuntimeProtocol.swift @@ -27,4 +27,4 @@ public protocol BedrockAgentRuntimeProtocol: Sendable { func retrieve(input: RetrieveInput) async throws -> RetrieveOutput } -extension BedrockAgentRuntimeClient: @retroactive @unchecked Sendable, BedrockAgentRuntimeProtocol {} \ No newline at end of file +extension BedrockAgentRuntimeClient: @retroactive @unchecked Sendable, BedrockAgentRuntimeProtocol {} diff --git a/Sources/BedrockService/Protocols/BedrockConfigProtocol.swift b/Sources/BedrockService/Protocols/BedrockConfigProtocol.swift index 355c176b..c2ef0a6a 100644 --- a/Sources/BedrockService/Protocols/BedrockConfigProtocol.swift +++ b/Sources/BedrockService/Protocols/BedrockConfigProtocol.swift @@ -14,8 +14,8 @@ //===----------------------------------------------------------------------===// import AWSBedrock -import AWSBedrockRuntime import AWSBedrockAgentRuntime +import AWSBedrockRuntime import ClientRuntime import SmithyHTTPAuthAPI import SmithyIdentity diff --git a/Sources/BedrockService/RetrieveResult.swift b/Sources/BedrockService/RetrieveResult.swift index 690abaf0..8e1dc7c0 100644 --- a/Sources/BedrockService/RetrieveResult.swift +++ b/Sources/BedrockService/RetrieveResult.swift @@ -31,22 +31,22 @@ struct SerializableResult: Codable { public struct RetrieveResult: Sendable { public let output: RetrieveOutput - + public init(_ output: RetrieveOutput) { self.output = output } - + public var results: [RAGRetrievalResult]? { - return output.retrievalResults + output.retrievalResults } - + public func bestMatch() -> RAGRetrievalResult? { - return output.retrievalResults?.max { ($0.score ?? 0) < ($1.score ?? 0) } + output.retrievalResults?.max { ($0.score ?? 0) < ($1.score ?? 0) } } - + public func toJSON() throws -> String { guard let results = output.retrievalResults else { return "[]" } - + let serializableResults = results.map { result in SerializableResult( content: result.content?.text, @@ -54,8 +54,8 @@ public struct RetrieveResult: Sendable { source: result.location?.s3Location?.uri ) } - + let jsonData = try JSONEncoder().encode(serializableResults) return String(data: jsonData, encoding: .utf8) ?? "[]" } -} \ No newline at end of file +} From 7061b0046bba3963bc9baf9d9f4f31be25a07722 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Stormacq?= Date: Thu, 23 Oct 2025 20:52:26 +0200 Subject: [PATCH 04/10] Update Sources/BedrockService/BedrockService+AgentRuntime.swift Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- Sources/BedrockService/BedrockService+AgentRuntime.swift | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Sources/BedrockService/BedrockService+AgentRuntime.swift b/Sources/BedrockService/BedrockService+AgentRuntime.swift index f072acba..e2fa60e0 100644 --- a/Sources/BedrockService/BedrockService+AgentRuntime.swift +++ b/Sources/BedrockService/BedrockService+AgentRuntime.swift @@ -58,7 +58,8 @@ extension BedrockService { let input = RetrieveInput( knowledgeBaseId: knowledgeBaseId, - retrievalQuery: BedrockAgentRuntimeClientTypes.KnowledgeBaseQuery(text: retrievalQuery) + retrievalQuery: BedrockAgentRuntimeClientTypes.KnowledgeBaseQuery(text: retrievalQuery), + numberOfResults: numberOfResults ) do { From c0b81bebece6a4d8b2f18b861b7b967ad3ee6b65 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Stormacq?= Date: Thu, 23 Oct 2025 20:52:42 +0200 Subject: [PATCH 05/10] Update Sources/BedrockService/RetrieveResult.swift Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- Sources/BedrockService/RetrieveResult.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Sources/BedrockService/RetrieveResult.swift b/Sources/BedrockService/RetrieveResult.swift index 8e1dc7c0..0111ab98 100644 --- a/Sources/BedrockService/RetrieveResult.swift +++ b/Sources/BedrockService/RetrieveResult.swift @@ -23,7 +23,7 @@ import Foundation public typealias RAGRetrievalResult = BedrockAgentRuntimeClientTypes.KnowledgeBaseRetrievalResult -struct SerializableResult: Codable { +internal struct SerializableResult: Codable { let content: String? let score: Double? let source: String? From f43297e65e82335ee7f71b5252e1506b13905b7c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Stormacq?= Date: Thu, 23 Oct 2025 21:06:03 +0200 Subject: [PATCH 06/10] provide a convenience wrapper around retrieveinput --- .../BedrockService+AgentRuntime.swift | 6 +-- Sources/BedrockService/RetrieveRequest.swift | 44 +++++++++++++++++++ 2 files changed, 47 insertions(+), 3 deletions(-) create mode 100644 Sources/BedrockService/RetrieveRequest.swift diff --git a/Sources/BedrockService/BedrockService+AgentRuntime.swift b/Sources/BedrockService/BedrockService+AgentRuntime.swift index e2fa60e0..97651a89 100644 --- a/Sources/BedrockService/BedrockService+AgentRuntime.swift +++ b/Sources/BedrockService/BedrockService+AgentRuntime.swift @@ -56,14 +56,14 @@ extension BedrockService { ] ) - let input = RetrieveInput( + let request = RetrieveRequest( knowledgeBaseId: knowledgeBaseId, - retrievalQuery: BedrockAgentRuntimeClientTypes.KnowledgeBaseQuery(text: retrievalQuery), + retrievalQuery: retrievalQuery, numberOfResults: numberOfResults ) do { - let response = try await bedrockAgentRuntimeClient.retrieve(input: input) + let response = try await bedrockAgentRuntimeClient.retrieve(input: request.input) logger.trace("Successfully retrieved from knowledge base") return RetrieveResult(response) } catch { diff --git a/Sources/BedrockService/RetrieveRequest.swift b/Sources/BedrockService/RetrieveRequest.swift new file mode 100644 index 00000000..3228f6af --- /dev/null +++ b/Sources/BedrockService/RetrieveRequest.swift @@ -0,0 +1,44 @@ +//===----------------------------------------------------------------------===// +// +// This source file is part of the Swift Bedrock Library open source project +// +// Copyright (c) 2025 Amazon.com, Inc. or its affiliates +// and the Swift Bedrock Library project authors +// Licensed under Apache License v2.0 +// +// See LICENSE.txt for license information +// See CONTRIBUTORS.txt for the list of Swift Bedrock Library project authors +// +// SPDX-License-Identifier: Apache-2.0 +// +//===----------------------------------------------------------------------===// + +@preconcurrency import AWSBedrockAgentRuntime + +public struct RetrieveRequest: Sendable { + public let knowledgeBaseId: String + public let retrievalQuery: String + public let numberOfResults: Int + + public init( + knowledgeBaseId: String, + retrievalQuery: String, + numberOfResults: Int = 3 + ) { + self.knowledgeBaseId = knowledgeBaseId + self.retrievalQuery = retrievalQuery + self.numberOfResults = numberOfResults + } + + internal var input: RetrieveInput { + return RetrieveInput( + knowledgeBaseId: knowledgeBaseId, + retrievalConfiguration: BedrockAgentRuntimeClientTypes.KnowledgeBaseRetrievalConfiguration( + vectorSearchConfiguration: BedrockAgentRuntimeClientTypes.KnowledgeBaseVectorSearchConfiguration( + numberOfResults: numberOfResults + ) + ), + retrievalQuery: BedrockAgentRuntimeClientTypes.KnowledgeBaseQuery(text: retrievalQuery) + ) + } +} \ No newline at end of file From fc4553bae3d3365e5edacbb1d47184db8bb02a06 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Stormacq?= Date: Thu, 23 Oct 2025 21:07:40 +0200 Subject: [PATCH 07/10] add swift docc header --- .../BedrockService/BedrockService+AgentRuntime.swift | 8 ++++++-- .../Protocols/BedrockAgentRuntimeProtocol.swift | 9 ++++++++- Sources/BedrockService/RetrieveRequest.swift | 9 +++++++++ Sources/BedrockService/RetrieveResult.swift | 11 +++++++++++ 4 files changed, 34 insertions(+), 3 deletions(-) diff --git a/Sources/BedrockService/BedrockService+AgentRuntime.swift b/Sources/BedrockService/BedrockService+AgentRuntime.swift index 97651a89..9200fe0e 100644 --- a/Sources/BedrockService/BedrockService+AgentRuntime.swift +++ b/Sources/BedrockService/BedrockService+AgentRuntime.swift @@ -36,12 +36,16 @@ extension BedrockService { ) return BedrockAgentRuntimeClient(config: config) } - /// Retrieves information from a knowledge base + /// Retrieves information from a knowledge base for RAG applications + /// + /// This method queries an Amazon Bedrock knowledge base to retrieve relevant information + /// that can be used for Retrieval-Augmented Generation (RAG) applications. + /// /// - Parameters: /// - knowledgeBaseId: The unique identifier of the knowledge base to query /// - retrievalQuery: The query to search for in the knowledge base /// - numberOfResults: The number of results to return (optional, defaults to 3) - /// - Returns: RetrieveResult containing the retrieved results + /// - Returns: RetrieveResult containing the retrieved results with convenience methods /// - Throws: BedrockLibraryError or other errors from the underlying service public func retrieve( knowledgeBaseId: String, diff --git a/Sources/BedrockService/Protocols/BedrockAgentRuntimeProtocol.swift b/Sources/BedrockService/Protocols/BedrockAgentRuntimeProtocol.swift index 1c19eb8e..bfc5b71f 100644 --- a/Sources/BedrockService/Protocols/BedrockAgentRuntimeProtocol.swift +++ b/Sources/BedrockService/Protocols/BedrockAgentRuntimeProtocol.swift @@ -22,8 +22,15 @@ import FoundationEssentials import Foundation #endif -// Protocol allows writing mocks for unit tests +/// Protocol for Amazon Bedrock Agent Runtime operations +/// +/// This protocol allows writing mocks for unit tests and provides a clean interface +/// for knowledge base retrieval operations. public protocol BedrockAgentRuntimeProtocol: Sendable { + /// Retrieves information from a knowledge base + /// - Parameter input: The retrieve input containing query and configuration + /// - Returns: RetrieveOutput with the retrieved results + /// - Throws: Error if the retrieval operation fails func retrieve(input: RetrieveInput) async throws -> RetrieveOutput } diff --git a/Sources/BedrockService/RetrieveRequest.swift b/Sources/BedrockService/RetrieveRequest.swift index 3228f6af..dd732e10 100644 --- a/Sources/BedrockService/RetrieveRequest.swift +++ b/Sources/BedrockService/RetrieveRequest.swift @@ -15,11 +15,20 @@ @preconcurrency import AWSBedrockAgentRuntime +/// A request for retrieving information from a knowledge base public struct RetrieveRequest: Sendable { + /// The unique identifier of the knowledge base to query public let knowledgeBaseId: String + /// The query text to search for in the knowledge base public let retrievalQuery: String + /// The number of results to return public let numberOfResults: Int + /// Creates a new retrieve request + /// - Parameters: + /// - knowledgeBaseId: The unique identifier of the knowledge base to query + /// - retrievalQuery: The query text to search for in the knowledge base + /// - numberOfResults: The number of results to return (defaults to 3) public init( knowledgeBaseId: String, retrievalQuery: String, diff --git a/Sources/BedrockService/RetrieveResult.swift b/Sources/BedrockService/RetrieveResult.swift index 0111ab98..9eb07033 100644 --- a/Sources/BedrockService/RetrieveResult.swift +++ b/Sources/BedrockService/RetrieveResult.swift @@ -21,6 +21,7 @@ import FoundationEssentials import Foundation #endif +/// Type alias for knowledge base retrieval result public typealias RAGRetrievalResult = BedrockAgentRuntimeClientTypes.KnowledgeBaseRetrievalResult internal struct SerializableResult: Codable { @@ -29,21 +30,31 @@ internal struct SerializableResult: Codable { let source: String? } +/// A wrapper around RetrieveOutput providing convenient access to retrieval results public struct RetrieveResult: Sendable { + /// The underlying AWS SDK RetrieveOutput public let output: RetrieveOutput + /// Creates a new RetrieveResult from a RetrieveOutput + /// - Parameter output: The AWS SDK RetrieveOutput to wrap public init(_ output: RetrieveOutput) { self.output = output } + /// The retrieval results from the knowledge base query public var results: [RAGRetrievalResult]? { output.retrievalResults } + /// Returns the retrieval result with the highest relevance score + /// - Returns: The best matching result, or nil if no results public func bestMatch() -> RAGRetrievalResult? { output.retrievalResults?.max { ($0.score ?? 0) < ($1.score ?? 0) } } + /// Converts the retrieval results to JSON format for use with language models + /// - Returns: JSON string representation of the results + /// - Throws: Error if JSON encoding fails public func toJSON() throws -> String { guard let results = output.retrievalResults else { return "[]" } From ebc16714bdc57efcd08a23292bfbf5c46b4c1e70 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Stormacq?= Date: Thu, 23 Oct 2025 21:11:39 +0200 Subject: [PATCH 08/10] swift-format --- Sources/BedrockService/BedrockService+AgentRuntime.swift | 4 ++-- .../Protocols/BedrockAgentRuntimeProtocol.swift | 2 +- Sources/BedrockService/RetrieveRequest.swift | 8 ++++---- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/Sources/BedrockService/BedrockService+AgentRuntime.swift b/Sources/BedrockService/BedrockService+AgentRuntime.swift index 9200fe0e..dd720392 100644 --- a/Sources/BedrockService/BedrockService+AgentRuntime.swift +++ b/Sources/BedrockService/BedrockService+AgentRuntime.swift @@ -37,10 +37,10 @@ extension BedrockService { return BedrockAgentRuntimeClient(config: config) } /// Retrieves information from a knowledge base for RAG applications - /// + /// /// This method queries an Amazon Bedrock knowledge base to retrieve relevant information /// that can be used for Retrieval-Augmented Generation (RAG) applications. - /// + /// /// - Parameters: /// - knowledgeBaseId: The unique identifier of the knowledge base to query /// - retrievalQuery: The query to search for in the knowledge base diff --git a/Sources/BedrockService/Protocols/BedrockAgentRuntimeProtocol.swift b/Sources/BedrockService/Protocols/BedrockAgentRuntimeProtocol.swift index bfc5b71f..2e4b093c 100644 --- a/Sources/BedrockService/Protocols/BedrockAgentRuntimeProtocol.swift +++ b/Sources/BedrockService/Protocols/BedrockAgentRuntimeProtocol.swift @@ -23,7 +23,7 @@ import Foundation #endif /// Protocol for Amazon Bedrock Agent Runtime operations -/// +/// /// This protocol allows writing mocks for unit tests and provides a clean interface /// for knowledge base retrieval operations. public protocol BedrockAgentRuntimeProtocol: Sendable { diff --git a/Sources/BedrockService/RetrieveRequest.swift b/Sources/BedrockService/RetrieveRequest.swift index dd732e10..02859288 100644 --- a/Sources/BedrockService/RetrieveRequest.swift +++ b/Sources/BedrockService/RetrieveRequest.swift @@ -23,7 +23,7 @@ public struct RetrieveRequest: Sendable { public let retrievalQuery: String /// The number of results to return public let numberOfResults: Int - + /// Creates a new retrieve request /// - Parameters: /// - knowledgeBaseId: The unique identifier of the knowledge base to query @@ -38,9 +38,9 @@ public struct RetrieveRequest: Sendable { self.retrievalQuery = retrievalQuery self.numberOfResults = numberOfResults } - + internal var input: RetrieveInput { - return RetrieveInput( + RetrieveInput( knowledgeBaseId: knowledgeBaseId, retrievalConfiguration: BedrockAgentRuntimeClientTypes.KnowledgeBaseRetrievalConfiguration( vectorSearchConfiguration: BedrockAgentRuntimeClientTypes.KnowledgeBaseVectorSearchConfiguration( @@ -50,4 +50,4 @@ public struct RetrieveRequest: Sendable { retrievalQuery: BedrockAgentRuntimeClientTypes.KnowledgeBaseQuery(text: retrievalQuery) ) } -} \ No newline at end of file +} From b842ede328250b37c0d83760a46cb16f7c2e453e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Stormacq?= Date: Thu, 23 Oct 2025 21:16:42 +0200 Subject: [PATCH 09/10] move files to an agent runtime directory --- .../{ => AgentRuntime}/BedrockService+AgentRuntime.swift | 0 Sources/BedrockService/{ => AgentRuntime}/RetrieveRequest.swift | 0 Sources/BedrockService/{ => AgentRuntime}/RetrieveResult.swift | 0 3 files changed, 0 insertions(+), 0 deletions(-) rename Sources/BedrockService/{ => AgentRuntime}/BedrockService+AgentRuntime.swift (100%) rename Sources/BedrockService/{ => AgentRuntime}/RetrieveRequest.swift (100%) rename Sources/BedrockService/{ => AgentRuntime}/RetrieveResult.swift (100%) diff --git a/Sources/BedrockService/BedrockService+AgentRuntime.swift b/Sources/BedrockService/AgentRuntime/BedrockService+AgentRuntime.swift similarity index 100% rename from Sources/BedrockService/BedrockService+AgentRuntime.swift rename to Sources/BedrockService/AgentRuntime/BedrockService+AgentRuntime.swift diff --git a/Sources/BedrockService/RetrieveRequest.swift b/Sources/BedrockService/AgentRuntime/RetrieveRequest.swift similarity index 100% rename from Sources/BedrockService/RetrieveRequest.swift rename to Sources/BedrockService/AgentRuntime/RetrieveRequest.swift diff --git a/Sources/BedrockService/RetrieveResult.swift b/Sources/BedrockService/AgentRuntime/RetrieveResult.swift similarity index 100% rename from Sources/BedrockService/RetrieveResult.swift rename to Sources/BedrockService/AgentRuntime/RetrieveResult.swift From f8c37bb8ea29cf1c0a69c43ba4b057f6c1dfbfde Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Stormacq?= Date: Thu, 23 Oct 2025 21:28:08 +0200 Subject: [PATCH 10/10] rearrange files in different directory structure --- .../BedrockClientProtocol.swift | 0 .../{ => BedrockClient}/ListModels/ModelSummary.swift | 0 .../{Protocols => }/BedrockConfigProtocol.swift | 0 .../BedrockRuntimeAgentProtocol.swift} | 6 +++--- .../BedrockService+RuntimeAgent.swift} | 0 .../RetrieveRequest.swift | 0 .../RetrieveResult.swift | 0 .../BedrockRuntimeClientProtocol.swift | 0 .../Converse/BedrockService+Converse.swift | 0 .../Converse/BedrockService+ConverseStreaming.swift | 0 .../Converse/ContentBlocks/Content.swift | 0 .../Converse/ContentBlocks/DocumentBlock.swift | 0 .../Converse/ContentBlocks/DocumentToJSON.swift | 0 .../Converse/ContentBlocks/ImageBlock.swift | 0 .../Converse/ContentBlocks/JSONtoDocument.swift | 0 .../Converse/ContentBlocks/ReasoningBlock.swift | 0 .../Converse/ContentBlocks/S3Location.swift | 0 .../Converse/ContentBlocks/ToolResultBlock.swift | 0 .../Converse/ContentBlocks/ToolUseBlock.swift | 0 .../Converse/ContentBlocks/VideoBlock.swift | 0 .../{ => BedrockRuntimeClient}/Converse/ConverseReply.swift | 0 .../Converse/ConverseRequest.swift | 0 .../Converse/ConverseRequestBuilder.swift | 0 .../Converse/ConverseRequestStreaming.swift | 0 .../Converse/ConverseResponseStreaming.swift | 0 .../{ => BedrockRuntimeClient}/Converse/History.swift | 0 .../{ => BedrockRuntimeClient}/Converse/JSON.swift | 0 .../{ => BedrockRuntimeClient}/Converse/Message.swift | 0 .../{ => BedrockRuntimeClient}/Converse/Role.swift | 0 .../Converse/Streaming/ConverseReplyStream.swift | 0 .../Converse/Streaming/ConverseStreamElement.swift | 0 .../Converse/Streaming/ResponseMetaData.swift | 0 .../Converse/Streaming/ToolUseStart.swift | 0 .../{ => BedrockRuntimeClient}/Converse/Tool.swift | 0 .../BedrockService+ImageParameterValidation.swift | 0 .../InvokeModel/BedrockService+InvokeModelEmbeddings.swift | 0 .../InvokeModel/BedrockService+InvokeModelImage.swift | 0 .../InvokeModel/BedrockService+InvokeModelText.swift | 0 .../InvokeModel/ContentType.swift | 0 .../{ => BedrockRuntimeClient}/InvokeModel/Embeddings.swift | 0 .../InvokeModel/ImageGenerationOutput.swift | 0 .../InvokeModel/ImageResolution.swift | 0 .../InvokeModel/InvokeModelRequest.swift | 0 .../InvokeModel/InvokeModelResponse.swift | 0 .../{ => BedrockRuntimeClient}/InvokeModel/Protocols.swift | 0 .../InvokeModel/TextCompletion.swift | 0 .../Modalities/ConverseFeature.swift | 0 .../Modalities/ConverseModality.swift | 0 .../Modalities/CrossRegionInference.swift | 0 .../Modalities/EmbeddingsModality.swift | 0 .../Modalities/ImageModality.swift | 0 .../{ => BedrockRuntimeClient}/Modalities/Modality.swift | 0 .../Modalities/StandardConverse.swift | 0 .../Modalities/TextModality.swift | 0 .../Parameters/ConverseParameters.swift | 0 .../Parameters/EmbeddingsParameters.swift | 0 .../Parameters/ImageGenerationParameters.swift | 0 .../Parameters/ParameterName.swift | 0 .../{ => BedrockRuntimeClient}/Parameters/Parameters.swift | 0 .../Parameters/TextGenerationParameters.swift | 0 Sources/BedrockService/BedrockService.swift | 4 ++-- Sources/BedrockService/{ => Models}/BedrockModel.swift | 0 62 files changed, 5 insertions(+), 5 deletions(-) rename Sources/BedrockService/{Protocols => BedrockClient}/BedrockClientProtocol.swift (100%) rename Sources/BedrockService/{ => BedrockClient}/ListModels/ModelSummary.swift (100%) rename Sources/BedrockService/{Protocols => }/BedrockConfigProtocol.swift (100%) rename Sources/BedrockService/{Protocols/BedrockAgentRuntimeProtocol.swift => BedrockRuntimeAgent/BedrockRuntimeAgentProtocol.swift} (89%) rename Sources/BedrockService/{AgentRuntime/BedrockService+AgentRuntime.swift => BedrockRuntimeAgent/BedrockService+RuntimeAgent.swift} (100%) rename Sources/BedrockService/{AgentRuntime => BedrockRuntimeAgent}/RetrieveRequest.swift (100%) rename Sources/BedrockService/{AgentRuntime => BedrockRuntimeAgent}/RetrieveResult.swift (100%) rename Sources/BedrockService/{Protocols => BedrockRuntimeClient}/BedrockRuntimeClientProtocol.swift (100%) rename Sources/BedrockService/{ => BedrockRuntimeClient}/Converse/BedrockService+Converse.swift (100%) rename Sources/BedrockService/{ => BedrockRuntimeClient}/Converse/BedrockService+ConverseStreaming.swift (100%) rename Sources/BedrockService/{ => BedrockRuntimeClient}/Converse/ContentBlocks/Content.swift (100%) rename Sources/BedrockService/{ => BedrockRuntimeClient}/Converse/ContentBlocks/DocumentBlock.swift (100%) rename Sources/BedrockService/{ => BedrockRuntimeClient}/Converse/ContentBlocks/DocumentToJSON.swift (100%) rename Sources/BedrockService/{ => BedrockRuntimeClient}/Converse/ContentBlocks/ImageBlock.swift (100%) rename Sources/BedrockService/{ => BedrockRuntimeClient}/Converse/ContentBlocks/JSONtoDocument.swift (100%) rename Sources/BedrockService/{ => BedrockRuntimeClient}/Converse/ContentBlocks/ReasoningBlock.swift (100%) rename Sources/BedrockService/{ => BedrockRuntimeClient}/Converse/ContentBlocks/S3Location.swift (100%) rename Sources/BedrockService/{ => BedrockRuntimeClient}/Converse/ContentBlocks/ToolResultBlock.swift (100%) rename Sources/BedrockService/{ => BedrockRuntimeClient}/Converse/ContentBlocks/ToolUseBlock.swift (100%) rename Sources/BedrockService/{ => BedrockRuntimeClient}/Converse/ContentBlocks/VideoBlock.swift (100%) rename Sources/BedrockService/{ => BedrockRuntimeClient}/Converse/ConverseReply.swift (100%) rename Sources/BedrockService/{ => BedrockRuntimeClient}/Converse/ConverseRequest.swift (100%) rename Sources/BedrockService/{ => BedrockRuntimeClient}/Converse/ConverseRequestBuilder.swift (100%) rename Sources/BedrockService/{ => BedrockRuntimeClient}/Converse/ConverseRequestStreaming.swift (100%) rename Sources/BedrockService/{ => BedrockRuntimeClient}/Converse/ConverseResponseStreaming.swift (100%) rename Sources/BedrockService/{ => BedrockRuntimeClient}/Converse/History.swift (100%) rename Sources/BedrockService/{ => BedrockRuntimeClient}/Converse/JSON.swift (100%) rename Sources/BedrockService/{ => BedrockRuntimeClient}/Converse/Message.swift (100%) rename Sources/BedrockService/{ => BedrockRuntimeClient}/Converse/Role.swift (100%) rename Sources/BedrockService/{ => BedrockRuntimeClient}/Converse/Streaming/ConverseReplyStream.swift (100%) rename Sources/BedrockService/{ => BedrockRuntimeClient}/Converse/Streaming/ConverseStreamElement.swift (100%) rename Sources/BedrockService/{ => BedrockRuntimeClient}/Converse/Streaming/ResponseMetaData.swift (100%) rename Sources/BedrockService/{ => BedrockRuntimeClient}/Converse/Streaming/ToolUseStart.swift (100%) rename Sources/BedrockService/{ => BedrockRuntimeClient}/Converse/Tool.swift (100%) rename Sources/BedrockService/{ => BedrockRuntimeClient}/InvokeModel/BedrockService+ImageParameterValidation.swift (100%) rename Sources/BedrockService/{ => BedrockRuntimeClient}/InvokeModel/BedrockService+InvokeModelEmbeddings.swift (100%) rename Sources/BedrockService/{ => BedrockRuntimeClient}/InvokeModel/BedrockService+InvokeModelImage.swift (100%) rename Sources/BedrockService/{ => BedrockRuntimeClient}/InvokeModel/BedrockService+InvokeModelText.swift (100%) rename Sources/BedrockService/{ => BedrockRuntimeClient}/InvokeModel/ContentType.swift (100%) rename Sources/BedrockService/{ => BedrockRuntimeClient}/InvokeModel/Embeddings.swift (100%) rename Sources/BedrockService/{ => BedrockRuntimeClient}/InvokeModel/ImageGenerationOutput.swift (100%) rename Sources/BedrockService/{ => BedrockRuntimeClient}/InvokeModel/ImageResolution.swift (100%) rename Sources/BedrockService/{ => BedrockRuntimeClient}/InvokeModel/InvokeModelRequest.swift (100%) rename Sources/BedrockService/{ => BedrockRuntimeClient}/InvokeModel/InvokeModelResponse.swift (100%) rename Sources/BedrockService/{ => BedrockRuntimeClient}/InvokeModel/Protocols.swift (100%) rename Sources/BedrockService/{ => BedrockRuntimeClient}/InvokeModel/TextCompletion.swift (100%) rename Sources/BedrockService/{ => BedrockRuntimeClient}/Modalities/ConverseFeature.swift (100%) rename Sources/BedrockService/{ => BedrockRuntimeClient}/Modalities/ConverseModality.swift (100%) rename Sources/BedrockService/{ => BedrockRuntimeClient}/Modalities/CrossRegionInference.swift (100%) rename Sources/BedrockService/{ => BedrockRuntimeClient}/Modalities/EmbeddingsModality.swift (100%) rename Sources/BedrockService/{ => BedrockRuntimeClient}/Modalities/ImageModality.swift (100%) rename Sources/BedrockService/{ => BedrockRuntimeClient}/Modalities/Modality.swift (100%) rename Sources/BedrockService/{ => BedrockRuntimeClient}/Modalities/StandardConverse.swift (100%) rename Sources/BedrockService/{ => BedrockRuntimeClient}/Modalities/TextModality.swift (100%) rename Sources/BedrockService/{ => BedrockRuntimeClient}/Parameters/ConverseParameters.swift (100%) rename Sources/BedrockService/{ => BedrockRuntimeClient}/Parameters/EmbeddingsParameters.swift (100%) rename Sources/BedrockService/{ => BedrockRuntimeClient}/Parameters/ImageGenerationParameters.swift (100%) rename Sources/BedrockService/{ => BedrockRuntimeClient}/Parameters/ParameterName.swift (100%) rename Sources/BedrockService/{ => BedrockRuntimeClient}/Parameters/Parameters.swift (100%) rename Sources/BedrockService/{ => BedrockRuntimeClient}/Parameters/TextGenerationParameters.swift (100%) rename Sources/BedrockService/{ => Models}/BedrockModel.swift (100%) diff --git a/Sources/BedrockService/Protocols/BedrockClientProtocol.swift b/Sources/BedrockService/BedrockClient/BedrockClientProtocol.swift similarity index 100% rename from Sources/BedrockService/Protocols/BedrockClientProtocol.swift rename to Sources/BedrockService/BedrockClient/BedrockClientProtocol.swift diff --git a/Sources/BedrockService/ListModels/ModelSummary.swift b/Sources/BedrockService/BedrockClient/ListModels/ModelSummary.swift similarity index 100% rename from Sources/BedrockService/ListModels/ModelSummary.swift rename to Sources/BedrockService/BedrockClient/ListModels/ModelSummary.swift diff --git a/Sources/BedrockService/Protocols/BedrockConfigProtocol.swift b/Sources/BedrockService/BedrockConfigProtocol.swift similarity index 100% rename from Sources/BedrockService/Protocols/BedrockConfigProtocol.swift rename to Sources/BedrockService/BedrockConfigProtocol.swift diff --git a/Sources/BedrockService/Protocols/BedrockAgentRuntimeProtocol.swift b/Sources/BedrockService/BedrockRuntimeAgent/BedrockRuntimeAgentProtocol.swift similarity index 89% rename from Sources/BedrockService/Protocols/BedrockAgentRuntimeProtocol.swift rename to Sources/BedrockService/BedrockRuntimeAgent/BedrockRuntimeAgentProtocol.swift index 2e4b093c..3bda2c5c 100644 --- a/Sources/BedrockService/Protocols/BedrockAgentRuntimeProtocol.swift +++ b/Sources/BedrockService/BedrockRuntimeAgent/BedrockRuntimeAgentProtocol.swift @@ -22,11 +22,11 @@ import FoundationEssentials import Foundation #endif -/// Protocol for Amazon Bedrock Agent Runtime operations +/// Protocol for Amazon Bedrock Runtime Agent operations /// /// This protocol allows writing mocks for unit tests and provides a clean interface /// for knowledge base retrieval operations. -public protocol BedrockAgentRuntimeProtocol: Sendable { +public protocol BedrockRuntimeAgentProtocol: Sendable { /// Retrieves information from a knowledge base /// - Parameter input: The retrieve input containing query and configuration /// - Returns: RetrieveOutput with the retrieved results @@ -34,4 +34,4 @@ public protocol BedrockAgentRuntimeProtocol: Sendable { func retrieve(input: RetrieveInput) async throws -> RetrieveOutput } -extension BedrockAgentRuntimeClient: @retroactive @unchecked Sendable, BedrockAgentRuntimeProtocol {} +extension BedrockAgentRuntimeClient: @retroactive @unchecked Sendable, BedrockRuntimeAgentProtocol {} diff --git a/Sources/BedrockService/AgentRuntime/BedrockService+AgentRuntime.swift b/Sources/BedrockService/BedrockRuntimeAgent/BedrockService+RuntimeAgent.swift similarity index 100% rename from Sources/BedrockService/AgentRuntime/BedrockService+AgentRuntime.swift rename to Sources/BedrockService/BedrockRuntimeAgent/BedrockService+RuntimeAgent.swift diff --git a/Sources/BedrockService/AgentRuntime/RetrieveRequest.swift b/Sources/BedrockService/BedrockRuntimeAgent/RetrieveRequest.swift similarity index 100% rename from Sources/BedrockService/AgentRuntime/RetrieveRequest.swift rename to Sources/BedrockService/BedrockRuntimeAgent/RetrieveRequest.swift diff --git a/Sources/BedrockService/AgentRuntime/RetrieveResult.swift b/Sources/BedrockService/BedrockRuntimeAgent/RetrieveResult.swift similarity index 100% rename from Sources/BedrockService/AgentRuntime/RetrieveResult.swift rename to Sources/BedrockService/BedrockRuntimeAgent/RetrieveResult.swift diff --git a/Sources/BedrockService/Protocols/BedrockRuntimeClientProtocol.swift b/Sources/BedrockService/BedrockRuntimeClient/BedrockRuntimeClientProtocol.swift similarity index 100% rename from Sources/BedrockService/Protocols/BedrockRuntimeClientProtocol.swift rename to Sources/BedrockService/BedrockRuntimeClient/BedrockRuntimeClientProtocol.swift diff --git a/Sources/BedrockService/Converse/BedrockService+Converse.swift b/Sources/BedrockService/BedrockRuntimeClient/Converse/BedrockService+Converse.swift similarity index 100% rename from Sources/BedrockService/Converse/BedrockService+Converse.swift rename to Sources/BedrockService/BedrockRuntimeClient/Converse/BedrockService+Converse.swift diff --git a/Sources/BedrockService/Converse/BedrockService+ConverseStreaming.swift b/Sources/BedrockService/BedrockRuntimeClient/Converse/BedrockService+ConverseStreaming.swift similarity index 100% rename from Sources/BedrockService/Converse/BedrockService+ConverseStreaming.swift rename to Sources/BedrockService/BedrockRuntimeClient/Converse/BedrockService+ConverseStreaming.swift diff --git a/Sources/BedrockService/Converse/ContentBlocks/Content.swift b/Sources/BedrockService/BedrockRuntimeClient/Converse/ContentBlocks/Content.swift similarity index 100% rename from Sources/BedrockService/Converse/ContentBlocks/Content.swift rename to Sources/BedrockService/BedrockRuntimeClient/Converse/ContentBlocks/Content.swift diff --git a/Sources/BedrockService/Converse/ContentBlocks/DocumentBlock.swift b/Sources/BedrockService/BedrockRuntimeClient/Converse/ContentBlocks/DocumentBlock.swift similarity index 100% rename from Sources/BedrockService/Converse/ContentBlocks/DocumentBlock.swift rename to Sources/BedrockService/BedrockRuntimeClient/Converse/ContentBlocks/DocumentBlock.swift diff --git a/Sources/BedrockService/Converse/ContentBlocks/DocumentToJSON.swift b/Sources/BedrockService/BedrockRuntimeClient/Converse/ContentBlocks/DocumentToJSON.swift similarity index 100% rename from Sources/BedrockService/Converse/ContentBlocks/DocumentToJSON.swift rename to Sources/BedrockService/BedrockRuntimeClient/Converse/ContentBlocks/DocumentToJSON.swift diff --git a/Sources/BedrockService/Converse/ContentBlocks/ImageBlock.swift b/Sources/BedrockService/BedrockRuntimeClient/Converse/ContentBlocks/ImageBlock.swift similarity index 100% rename from Sources/BedrockService/Converse/ContentBlocks/ImageBlock.swift rename to Sources/BedrockService/BedrockRuntimeClient/Converse/ContentBlocks/ImageBlock.swift diff --git a/Sources/BedrockService/Converse/ContentBlocks/JSONtoDocument.swift b/Sources/BedrockService/BedrockRuntimeClient/Converse/ContentBlocks/JSONtoDocument.swift similarity index 100% rename from Sources/BedrockService/Converse/ContentBlocks/JSONtoDocument.swift rename to Sources/BedrockService/BedrockRuntimeClient/Converse/ContentBlocks/JSONtoDocument.swift diff --git a/Sources/BedrockService/Converse/ContentBlocks/ReasoningBlock.swift b/Sources/BedrockService/BedrockRuntimeClient/Converse/ContentBlocks/ReasoningBlock.swift similarity index 100% rename from Sources/BedrockService/Converse/ContentBlocks/ReasoningBlock.swift rename to Sources/BedrockService/BedrockRuntimeClient/Converse/ContentBlocks/ReasoningBlock.swift diff --git a/Sources/BedrockService/Converse/ContentBlocks/S3Location.swift b/Sources/BedrockService/BedrockRuntimeClient/Converse/ContentBlocks/S3Location.swift similarity index 100% rename from Sources/BedrockService/Converse/ContentBlocks/S3Location.swift rename to Sources/BedrockService/BedrockRuntimeClient/Converse/ContentBlocks/S3Location.swift diff --git a/Sources/BedrockService/Converse/ContentBlocks/ToolResultBlock.swift b/Sources/BedrockService/BedrockRuntimeClient/Converse/ContentBlocks/ToolResultBlock.swift similarity index 100% rename from Sources/BedrockService/Converse/ContentBlocks/ToolResultBlock.swift rename to Sources/BedrockService/BedrockRuntimeClient/Converse/ContentBlocks/ToolResultBlock.swift diff --git a/Sources/BedrockService/Converse/ContentBlocks/ToolUseBlock.swift b/Sources/BedrockService/BedrockRuntimeClient/Converse/ContentBlocks/ToolUseBlock.swift similarity index 100% rename from Sources/BedrockService/Converse/ContentBlocks/ToolUseBlock.swift rename to Sources/BedrockService/BedrockRuntimeClient/Converse/ContentBlocks/ToolUseBlock.swift diff --git a/Sources/BedrockService/Converse/ContentBlocks/VideoBlock.swift b/Sources/BedrockService/BedrockRuntimeClient/Converse/ContentBlocks/VideoBlock.swift similarity index 100% rename from Sources/BedrockService/Converse/ContentBlocks/VideoBlock.swift rename to Sources/BedrockService/BedrockRuntimeClient/Converse/ContentBlocks/VideoBlock.swift diff --git a/Sources/BedrockService/Converse/ConverseReply.swift b/Sources/BedrockService/BedrockRuntimeClient/Converse/ConverseReply.swift similarity index 100% rename from Sources/BedrockService/Converse/ConverseReply.swift rename to Sources/BedrockService/BedrockRuntimeClient/Converse/ConverseReply.swift diff --git a/Sources/BedrockService/Converse/ConverseRequest.swift b/Sources/BedrockService/BedrockRuntimeClient/Converse/ConverseRequest.swift similarity index 100% rename from Sources/BedrockService/Converse/ConverseRequest.swift rename to Sources/BedrockService/BedrockRuntimeClient/Converse/ConverseRequest.swift diff --git a/Sources/BedrockService/Converse/ConverseRequestBuilder.swift b/Sources/BedrockService/BedrockRuntimeClient/Converse/ConverseRequestBuilder.swift similarity index 100% rename from Sources/BedrockService/Converse/ConverseRequestBuilder.swift rename to Sources/BedrockService/BedrockRuntimeClient/Converse/ConverseRequestBuilder.swift diff --git a/Sources/BedrockService/Converse/ConverseRequestStreaming.swift b/Sources/BedrockService/BedrockRuntimeClient/Converse/ConverseRequestStreaming.swift similarity index 100% rename from Sources/BedrockService/Converse/ConverseRequestStreaming.swift rename to Sources/BedrockService/BedrockRuntimeClient/Converse/ConverseRequestStreaming.swift diff --git a/Sources/BedrockService/Converse/ConverseResponseStreaming.swift b/Sources/BedrockService/BedrockRuntimeClient/Converse/ConverseResponseStreaming.swift similarity index 100% rename from Sources/BedrockService/Converse/ConverseResponseStreaming.swift rename to Sources/BedrockService/BedrockRuntimeClient/Converse/ConverseResponseStreaming.swift diff --git a/Sources/BedrockService/Converse/History.swift b/Sources/BedrockService/BedrockRuntimeClient/Converse/History.swift similarity index 100% rename from Sources/BedrockService/Converse/History.swift rename to Sources/BedrockService/BedrockRuntimeClient/Converse/History.swift diff --git a/Sources/BedrockService/Converse/JSON.swift b/Sources/BedrockService/BedrockRuntimeClient/Converse/JSON.swift similarity index 100% rename from Sources/BedrockService/Converse/JSON.swift rename to Sources/BedrockService/BedrockRuntimeClient/Converse/JSON.swift diff --git a/Sources/BedrockService/Converse/Message.swift b/Sources/BedrockService/BedrockRuntimeClient/Converse/Message.swift similarity index 100% rename from Sources/BedrockService/Converse/Message.swift rename to Sources/BedrockService/BedrockRuntimeClient/Converse/Message.swift diff --git a/Sources/BedrockService/Converse/Role.swift b/Sources/BedrockService/BedrockRuntimeClient/Converse/Role.swift similarity index 100% rename from Sources/BedrockService/Converse/Role.swift rename to Sources/BedrockService/BedrockRuntimeClient/Converse/Role.swift diff --git a/Sources/BedrockService/Converse/Streaming/ConverseReplyStream.swift b/Sources/BedrockService/BedrockRuntimeClient/Converse/Streaming/ConverseReplyStream.swift similarity index 100% rename from Sources/BedrockService/Converse/Streaming/ConverseReplyStream.swift rename to Sources/BedrockService/BedrockRuntimeClient/Converse/Streaming/ConverseReplyStream.swift diff --git a/Sources/BedrockService/Converse/Streaming/ConverseStreamElement.swift b/Sources/BedrockService/BedrockRuntimeClient/Converse/Streaming/ConverseStreamElement.swift similarity index 100% rename from Sources/BedrockService/Converse/Streaming/ConverseStreamElement.swift rename to Sources/BedrockService/BedrockRuntimeClient/Converse/Streaming/ConverseStreamElement.swift diff --git a/Sources/BedrockService/Converse/Streaming/ResponseMetaData.swift b/Sources/BedrockService/BedrockRuntimeClient/Converse/Streaming/ResponseMetaData.swift similarity index 100% rename from Sources/BedrockService/Converse/Streaming/ResponseMetaData.swift rename to Sources/BedrockService/BedrockRuntimeClient/Converse/Streaming/ResponseMetaData.swift diff --git a/Sources/BedrockService/Converse/Streaming/ToolUseStart.swift b/Sources/BedrockService/BedrockRuntimeClient/Converse/Streaming/ToolUseStart.swift similarity index 100% rename from Sources/BedrockService/Converse/Streaming/ToolUseStart.swift rename to Sources/BedrockService/BedrockRuntimeClient/Converse/Streaming/ToolUseStart.swift diff --git a/Sources/BedrockService/Converse/Tool.swift b/Sources/BedrockService/BedrockRuntimeClient/Converse/Tool.swift similarity index 100% rename from Sources/BedrockService/Converse/Tool.swift rename to Sources/BedrockService/BedrockRuntimeClient/Converse/Tool.swift diff --git a/Sources/BedrockService/InvokeModel/BedrockService+ImageParameterValidation.swift b/Sources/BedrockService/BedrockRuntimeClient/InvokeModel/BedrockService+ImageParameterValidation.swift similarity index 100% rename from Sources/BedrockService/InvokeModel/BedrockService+ImageParameterValidation.swift rename to Sources/BedrockService/BedrockRuntimeClient/InvokeModel/BedrockService+ImageParameterValidation.swift diff --git a/Sources/BedrockService/InvokeModel/BedrockService+InvokeModelEmbeddings.swift b/Sources/BedrockService/BedrockRuntimeClient/InvokeModel/BedrockService+InvokeModelEmbeddings.swift similarity index 100% rename from Sources/BedrockService/InvokeModel/BedrockService+InvokeModelEmbeddings.swift rename to Sources/BedrockService/BedrockRuntimeClient/InvokeModel/BedrockService+InvokeModelEmbeddings.swift diff --git a/Sources/BedrockService/InvokeModel/BedrockService+InvokeModelImage.swift b/Sources/BedrockService/BedrockRuntimeClient/InvokeModel/BedrockService+InvokeModelImage.swift similarity index 100% rename from Sources/BedrockService/InvokeModel/BedrockService+InvokeModelImage.swift rename to Sources/BedrockService/BedrockRuntimeClient/InvokeModel/BedrockService+InvokeModelImage.swift diff --git a/Sources/BedrockService/InvokeModel/BedrockService+InvokeModelText.swift b/Sources/BedrockService/BedrockRuntimeClient/InvokeModel/BedrockService+InvokeModelText.swift similarity index 100% rename from Sources/BedrockService/InvokeModel/BedrockService+InvokeModelText.swift rename to Sources/BedrockService/BedrockRuntimeClient/InvokeModel/BedrockService+InvokeModelText.swift diff --git a/Sources/BedrockService/InvokeModel/ContentType.swift b/Sources/BedrockService/BedrockRuntimeClient/InvokeModel/ContentType.swift similarity index 100% rename from Sources/BedrockService/InvokeModel/ContentType.swift rename to Sources/BedrockService/BedrockRuntimeClient/InvokeModel/ContentType.swift diff --git a/Sources/BedrockService/InvokeModel/Embeddings.swift b/Sources/BedrockService/BedrockRuntimeClient/InvokeModel/Embeddings.swift similarity index 100% rename from Sources/BedrockService/InvokeModel/Embeddings.swift rename to Sources/BedrockService/BedrockRuntimeClient/InvokeModel/Embeddings.swift diff --git a/Sources/BedrockService/InvokeModel/ImageGenerationOutput.swift b/Sources/BedrockService/BedrockRuntimeClient/InvokeModel/ImageGenerationOutput.swift similarity index 100% rename from Sources/BedrockService/InvokeModel/ImageGenerationOutput.swift rename to Sources/BedrockService/BedrockRuntimeClient/InvokeModel/ImageGenerationOutput.swift diff --git a/Sources/BedrockService/InvokeModel/ImageResolution.swift b/Sources/BedrockService/BedrockRuntimeClient/InvokeModel/ImageResolution.swift similarity index 100% rename from Sources/BedrockService/InvokeModel/ImageResolution.swift rename to Sources/BedrockService/BedrockRuntimeClient/InvokeModel/ImageResolution.swift diff --git a/Sources/BedrockService/InvokeModel/InvokeModelRequest.swift b/Sources/BedrockService/BedrockRuntimeClient/InvokeModel/InvokeModelRequest.swift similarity index 100% rename from Sources/BedrockService/InvokeModel/InvokeModelRequest.swift rename to Sources/BedrockService/BedrockRuntimeClient/InvokeModel/InvokeModelRequest.swift diff --git a/Sources/BedrockService/InvokeModel/InvokeModelResponse.swift b/Sources/BedrockService/BedrockRuntimeClient/InvokeModel/InvokeModelResponse.swift similarity index 100% rename from Sources/BedrockService/InvokeModel/InvokeModelResponse.swift rename to Sources/BedrockService/BedrockRuntimeClient/InvokeModel/InvokeModelResponse.swift diff --git a/Sources/BedrockService/InvokeModel/Protocols.swift b/Sources/BedrockService/BedrockRuntimeClient/InvokeModel/Protocols.swift similarity index 100% rename from Sources/BedrockService/InvokeModel/Protocols.swift rename to Sources/BedrockService/BedrockRuntimeClient/InvokeModel/Protocols.swift diff --git a/Sources/BedrockService/InvokeModel/TextCompletion.swift b/Sources/BedrockService/BedrockRuntimeClient/InvokeModel/TextCompletion.swift similarity index 100% rename from Sources/BedrockService/InvokeModel/TextCompletion.swift rename to Sources/BedrockService/BedrockRuntimeClient/InvokeModel/TextCompletion.swift diff --git a/Sources/BedrockService/Modalities/ConverseFeature.swift b/Sources/BedrockService/BedrockRuntimeClient/Modalities/ConverseFeature.swift similarity index 100% rename from Sources/BedrockService/Modalities/ConverseFeature.swift rename to Sources/BedrockService/BedrockRuntimeClient/Modalities/ConverseFeature.swift diff --git a/Sources/BedrockService/Modalities/ConverseModality.swift b/Sources/BedrockService/BedrockRuntimeClient/Modalities/ConverseModality.swift similarity index 100% rename from Sources/BedrockService/Modalities/ConverseModality.swift rename to Sources/BedrockService/BedrockRuntimeClient/Modalities/ConverseModality.swift diff --git a/Sources/BedrockService/Modalities/CrossRegionInference.swift b/Sources/BedrockService/BedrockRuntimeClient/Modalities/CrossRegionInference.swift similarity index 100% rename from Sources/BedrockService/Modalities/CrossRegionInference.swift rename to Sources/BedrockService/BedrockRuntimeClient/Modalities/CrossRegionInference.swift diff --git a/Sources/BedrockService/Modalities/EmbeddingsModality.swift b/Sources/BedrockService/BedrockRuntimeClient/Modalities/EmbeddingsModality.swift similarity index 100% rename from Sources/BedrockService/Modalities/EmbeddingsModality.swift rename to Sources/BedrockService/BedrockRuntimeClient/Modalities/EmbeddingsModality.swift diff --git a/Sources/BedrockService/Modalities/ImageModality.swift b/Sources/BedrockService/BedrockRuntimeClient/Modalities/ImageModality.swift similarity index 100% rename from Sources/BedrockService/Modalities/ImageModality.swift rename to Sources/BedrockService/BedrockRuntimeClient/Modalities/ImageModality.swift diff --git a/Sources/BedrockService/Modalities/Modality.swift b/Sources/BedrockService/BedrockRuntimeClient/Modalities/Modality.swift similarity index 100% rename from Sources/BedrockService/Modalities/Modality.swift rename to Sources/BedrockService/BedrockRuntimeClient/Modalities/Modality.swift diff --git a/Sources/BedrockService/Modalities/StandardConverse.swift b/Sources/BedrockService/BedrockRuntimeClient/Modalities/StandardConverse.swift similarity index 100% rename from Sources/BedrockService/Modalities/StandardConverse.swift rename to Sources/BedrockService/BedrockRuntimeClient/Modalities/StandardConverse.swift diff --git a/Sources/BedrockService/Modalities/TextModality.swift b/Sources/BedrockService/BedrockRuntimeClient/Modalities/TextModality.swift similarity index 100% rename from Sources/BedrockService/Modalities/TextModality.swift rename to Sources/BedrockService/BedrockRuntimeClient/Modalities/TextModality.swift diff --git a/Sources/BedrockService/Parameters/ConverseParameters.swift b/Sources/BedrockService/BedrockRuntimeClient/Parameters/ConverseParameters.swift similarity index 100% rename from Sources/BedrockService/Parameters/ConverseParameters.swift rename to Sources/BedrockService/BedrockRuntimeClient/Parameters/ConverseParameters.swift diff --git a/Sources/BedrockService/Parameters/EmbeddingsParameters.swift b/Sources/BedrockService/BedrockRuntimeClient/Parameters/EmbeddingsParameters.swift similarity index 100% rename from Sources/BedrockService/Parameters/EmbeddingsParameters.swift rename to Sources/BedrockService/BedrockRuntimeClient/Parameters/EmbeddingsParameters.swift diff --git a/Sources/BedrockService/Parameters/ImageGenerationParameters.swift b/Sources/BedrockService/BedrockRuntimeClient/Parameters/ImageGenerationParameters.swift similarity index 100% rename from Sources/BedrockService/Parameters/ImageGenerationParameters.swift rename to Sources/BedrockService/BedrockRuntimeClient/Parameters/ImageGenerationParameters.swift diff --git a/Sources/BedrockService/Parameters/ParameterName.swift b/Sources/BedrockService/BedrockRuntimeClient/Parameters/ParameterName.swift similarity index 100% rename from Sources/BedrockService/Parameters/ParameterName.swift rename to Sources/BedrockService/BedrockRuntimeClient/Parameters/ParameterName.swift diff --git a/Sources/BedrockService/Parameters/Parameters.swift b/Sources/BedrockService/BedrockRuntimeClient/Parameters/Parameters.swift similarity index 100% rename from Sources/BedrockService/Parameters/Parameters.swift rename to Sources/BedrockService/BedrockRuntimeClient/Parameters/Parameters.swift diff --git a/Sources/BedrockService/Parameters/TextGenerationParameters.swift b/Sources/BedrockService/BedrockRuntimeClient/Parameters/TextGenerationParameters.swift similarity index 100% rename from Sources/BedrockService/Parameters/TextGenerationParameters.swift rename to Sources/BedrockService/BedrockRuntimeClient/Parameters/TextGenerationParameters.swift diff --git a/Sources/BedrockService/BedrockService.swift b/Sources/BedrockService/BedrockService.swift index 11e8e1d1..6f23a54f 100644 --- a/Sources/BedrockService/BedrockService.swift +++ b/Sources/BedrockService/BedrockService.swift @@ -39,7 +39,7 @@ public struct BedrockService: Sendable { package let logger: Logging.Logger package let bedrockClient: BedrockClientProtocol package let bedrockRuntimeClient: BedrockRuntimeClientProtocol - package let bedrockAgentRuntimeClient: BedrockAgentRuntimeProtocol + package let bedrockAgentRuntimeClient: BedrockRuntimeAgentProtocol // MARK: - Initialization @@ -57,7 +57,7 @@ public struct BedrockService: Sendable { logger: Logging.Logger? = nil, bedrockClient: BedrockClientProtocol? = nil, bedrockRuntimeClient: BedrockRuntimeClientProtocol? = nil, - bedrockAgentRuntimeClient: BedrockAgentRuntimeProtocol? = nil, + bedrockAgentRuntimeClient: BedrockRuntimeAgentProtocol? = nil, authentication: BedrockAuthentication = .default ) async throws { self.logger = logger ?? BedrockService.createLogger("bedrock.service") diff --git a/Sources/BedrockService/BedrockModel.swift b/Sources/BedrockService/Models/BedrockModel.swift similarity index 100% rename from Sources/BedrockService/BedrockModel.swift rename to Sources/BedrockService/Models/BedrockModel.swift