Skip to content

Commit 67f49cf

Browse files
committed
addopt interface changes
1 parent fb3e4b9 commit 67f49cf

File tree

3 files changed

+24
-21
lines changed

3 files changed

+24
-21
lines changed

Package.resolved

Lines changed: 12 additions & 12 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Sources/AnthropicSwiftSDK/Network/MessagesRequest.swift

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ public struct MessagesRequest: Encodable {
6464
temperature: Double? = nil,
6565
topP: Double? = nil,
6666
topK: Int? = nil,
67-
tools: String? = nil,
67+
tools: [Tool]? = nil,
6868
toolChoice: ToolChoice = .auto
6969
) {
7070
self.model = model
@@ -77,12 +77,7 @@ public struct MessagesRequest: Encodable {
7777
self.temperature = temperature
7878
self.topP = topP
7979
self.topK = topK
80-
let tool = tools?.replacingOccurrences(of: "\n", with: "")
81-
if let data = tool?.data(using: .utf8) {
82-
self.tools = try? anthropicJSONDecoder.decode([Tool].self, from: data)
83-
} else {
84-
self.tools = nil
85-
}
80+
self.tools = tools
8681
self.toolChoice = toolChoice
8782
}
8883
}

Tests/AnthropicSwiftSDKTests/Entity/Streaming/StreamingMessageDeltaResponseTests.swift

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,12 +66,20 @@ final class StreamingMessageDeltaResponseTests: XCTestCase {
6666

6767
func testToolContainerIsExecutedByResponse() async throws {
6868
struct MockToolContiner: ToolContainer {
69+
var allToolsJSONString: String {
70+
""
71+
}
72+
73+
var service: FunctionCallingService {
74+
.claude
75+
}
76+
6977
func execute(methodName name: String, parameters: [String : Any]) async -> String {
7078
return "executed,\(name),\(parameters.keys.first ?? "")"
7179
}
7280

73-
var allTools: String {
74-
""
81+
var allTools: [Tool]? {
82+
nil
7583
}
7684
}
7785

0 commit comments

Comments
 (0)