Skip to content

Commit 898fc96

Browse files
authored
Merge pull request #24 from fumito-ito/fix/remove-unused-property-for-bedrock
bedrock client should use model passed in `message` methods
2 parents 4bee087 + 2fb42c2 commit 898fc96

File tree

4 files changed

+7
-29
lines changed

4 files changed

+7
-29
lines changed

Sources/AnthropicSwiftSDK-Bedrock/AnthropicBedrockClient.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ public final class AnthropicBedrockClient {
1818
AnthropicVersion.custom("bedrock-2023-05-31").stringfy
1919
}
2020

21-
init(client: BedrockRuntimeClient, model: Model) {
22-
self.messages = .init(client: client, model: model)
21+
init(client: BedrockRuntimeClient) {
22+
self.messages = .init(client: client)
2323
}
2424
}

Sources/AnthropicSwiftSDK-Bedrock/Extensions/BedrockClient+Extension.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,16 +16,16 @@ public extension BedrockRuntimeClient {
1616
/// - client: Bedrock runtime client
1717
/// - model: Claude model, Bedrock supports Haiku or Sonnet instance type.
1818
/// - Returns: Client using Claude through Bedrock
19-
static func useAnthropic(_ client: BedrockRuntimeClient, model: Model) -> AnthropicBedrockClient {
20-
AnthropicBedrockClient(client: client, model: model)
19+
static func useAnthropic(_ client: BedrockRuntimeClient) -> AnthropicBedrockClient {
20+
AnthropicBedrockClient(client: client)
2121
}
2222

2323
/// Create a client using Claude through Bedrock
2424
///
2525
/// - Parameters:
2626
/// - model: Claude model, Bedrock supports Haiku or Sonnet instance type.
2727
/// - Returns: Client using Claude through Bedrock
28-
func useAnthropic(model: Model) -> AnthropicBedrockClient {
29-
AnthropicBedrockClient(client: self, model: model)
28+
func useAnthropic() -> AnthropicBedrockClient {
29+
AnthropicBedrockClient(client: self)
3030
}
3131
}

Sources/AnthropicSwiftSDK-Bedrock/Messages.swift

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,9 @@ public struct Messages {
1616
public let requestContentType = "application/json"
1717
/// Bedrock API Client
1818
public let client: BedrockRuntimeClient
19-
/// Claude model for this client
20-
public let model: Model
2119

22-
init(client: BedrockRuntimeClient, model: Model) {
20+
init(client: BedrockRuntimeClient) {
2321
self.client = client
24-
self.model = model
2522
}
2623

2724
/// Creates a message using the specified parameters and sends a request to the Anthropic API asynchronously.

Tests/AnthropicSwiftSDK-BedrockTests/AnthropicBedrockClientTests.swift

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -11,25 +11,6 @@ import AnthropicSwiftSDK
1111
import AWSBedrockRuntime
1212

1313
final class AnthropicBedrockClientTests: XCTestCase {
14-
func testClientUsePassedAnthropicModel() throws {
15-
let client = try BedrockRuntimeClient(region: "US")
16-
17-
var anthropic = BedrockRuntimeClient.useAnthropic(client, model: .claude_3_Haiku)
18-
XCTAssertEqual(anthropic.messages.model.description, Model.claude_3_Haiku.description)
19-
20-
anthropic = BedrockRuntimeClient.useAnthropic(client, model: .claude_3_Sonnet)
21-
XCTAssertEqual(anthropic.messages.model.description, Model.claude_3_Sonnet.description)
22-
23-
anthropic = BedrockRuntimeClient.useAnthropic(client, model: .claude_3_Opus)
24-
XCTAssertEqual(anthropic.messages.model.description, Model.claude_3_Opus.description)
25-
26-
anthropic = BedrockRuntimeClient.useAnthropic(client, model: .claude_3_5_Sonnet)
27-
XCTAssertEqual(anthropic.messages.model.description, Model.claude_3_5_Sonnet.description)
28-
29-
anthropic = BedrockRuntimeClient.useAnthropic(client, model: .custom("custom-model"))
30-
XCTAssertEqual(anthropic.messages.model.description, "custom-model")
31-
}
32-
3314
func testInvokeModelContainEncodedMessageRequest() throws {
3415
let request = MessagesRequest(model: .claude_3_Haiku, messages: [Message(role: .user, content: [.text("Hello! Claude!")])], system: nil, maxTokens: 1024, metaData: MetaData(userId: "112234"), stopSequences: ["stop sequence"], stream: false, temperature: 0.4, topP: 1, topK: 2)
3516
let invokeModel = try InvokeModelInput(accept: "application/json", request: request, contentType: "application/json")

0 commit comments

Comments
 (0)